文本内容在行框中溢出.如果你加上大约span
个带轮廓或边框的东西,你会看到这一点:
#container {
width: full;
height: 200px;
background: #ffaaaa;
overflow: auto;
}
.content {
background: #aaffaa;
font-size: 8rem;
line-height: 1;
}
.content span {
border: 1px solid;
}
<div id="container">
<div class="content"><span>CONTENT</span></div>
<div class="content"><span>CONTENT</span></div>
<div class="content"><span>CONTENT</span></div>
</div>
你可以清楚地看到边界是如何溢出的.原因与line-height: 1
有关,它将行框的高度设置为小于文本内容的值
不要那样做.您可以控制行框的高度,但不能控制文本内容的高度.保留缺省值line-height
或使用更大的值
#container {
width: full;
height: 200px;
background: #ffaaaa;
overflow: auto;
}
.content {
background: #aaffaa;
font-size: 8rem;
/*line-height: 1;*/
}
.content span {
border: 1px solid;
}
<div id="container">
<div class="content"><span>CONTENT</span></div>
<div class="content"><span>CONTENT</span></div>
<div class="content"><span>CONTENT</span></div>
</div>
相关:Can specific text character change the line height?