我有一个CSS文件。使用line-height: 1em;
属性,文本如下所示:
并且没有该属性,它看起来像这样:
1em应该与现有的相同,但如果仔细观察,你会发现它们是不同的。为什么这些出现的方式不同?
body {
color: green;
font-family: Verdana, Arial, Geneva, Arial Black;
font-weight: normal;
background-color: #ffcf79;
font-size: 25px;
}
h1 {
text-decoration: underline;
font-size: 150%;
}
h2 {
text-decoration: underline;
font-size: 1.2em;
}
p.para1 {color: blue;}
p.para2 {color: purple;}
p.para3 {
color: purple;
font-size: 15px;
line-height: 1.5em;
background-color: #e5e4d7;
padding: 20px;
border-color: black;
border-width: 2px;
border-style: solid;
}
p.para4 {
color: black;
font-size: 15px;
line-height: 1.5em;
background-color: #e5e4d7;
padding: 20px;
border-color: black;
border-width: 2px;
border-style: solid;
margin: 20px;
margin-top: 50px;
margin-left: 400px;
}
.imagec {
display: block;
margin-left: auto;
margin-right: auto;
padding: 3px;
background-color: silver;
border-color: black;
border-style: solid;
}

<body>
<h1> The Fish Web Site </h1>
<p class="para1"> Welcome to the Fish Web Site. Everything you want to know about fish is in this web site. </p>
<img class="imagec" src="_images/barracuda.jpg">
<h2> This is a section on Bass fish </h2>
<p class="para2"> Bass fish live in lakes. The word for fish in Latin is <i>Pisces</i> </p>
<p class="para3"> A fish is any member of a paraphyletic group of organisms that consist of all gill-bearing aquatic craniate animals that lack limbs with digits. Included in this definition are the living hagfish, lampreys, and cartilaginous and bony fish, as well as various extinct related groups. Most fish are ectothermic ("cold-blooded"), allowing their body temperatures to vary as ambient temperatures change, though some of the large active swimmers like white shark and tuna can hold a higher core temperature. Fish are abundant in most bodies of water. They can be found in nearly all aquatic environments, from high mountain streams (e.g., char and gudgeon) to the abyssal and even hadal depths of the deepest oceans (e.g., gulpers and anglerfish). At 32,000 species, fish exhibit greater species diversity than any other group of vertebrates.</p>
<p class="para4"> A fish is any member of a paraphyletic group of organisms that consist of all gill-bearing aquatic craniate animals that lack limbs with digits. Included in this definition are the living hagfish, lampreys, and cartilaginous and bony fish,
as well as various extinct related groups. Most fish are ectothermic ("cold-blooded"), allowing their body temperatures to vary as ambient temperatures change, though some of the large active swimmers like white shark and tuna can hold a higher core temperature. Fish are abundant in most bodies of water. They can be found in nearly all aquatic environments, from high mountain streams (e.g., char and gudgeon) to the abyssal and even hadal depths of the deepest oceans (e.g., gulpers and anglerfish). At 32,000 species, fish exhibit greater species diversity than any other group of vertebrates.</p>
</body>
&#13;
答案 0 :(得分:0)
我没有看到浏览器的默认行高为1em的原因,因为在大多数情况下,两行之间没有空格只会导致可读性差。以下是我从官方消息来源可以找到的信息:
桌面浏览器(包括Firefox)使用大约1.2的默认值,具体取决于元素的font-family。 [MDN/line-height]