我试过将行高设置为 1em
,但是,字体上下仍有一些空间(大约 3px):
如何将网站的行高设置为与字体高度完全一致?
JSFiddle:http://jsfiddle.net/uovjzrn6/1/
HTML:
Hello, world!
CSS:
body {
font-size: 18px;
line-height: 1em;
}
最佳答案
引用以下示例 div
HTML5/CSS3:
HTML
<div id = "sample">
Hello, world!
</div>
CSS
body {
font-size: 18px;
padding:0;
margin:0;
}
#sample
{
height: 18px;
line-height: 18px;
background-color: #e0e0e0;
margin-top:-3px;
}
希望这可能有所帮助。
关于html - 如何使行高与字体高度匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30722224/