CSS如何使文本对齐背景颜色顶线
http://jsfiddle.net/5xR8V/
(填充顶部:- px 不工作)
<div class="a">
texttext
</div>
.a{
position: absolute;
top:100px;
width: 200px;
height: 19px;
background: #000000;
font-size: 20px;
color: #FFFFFF;
}
最佳答案
如果你想让它在顶部,但底部仍有空间:
line-height:19px;
padding-bottom:2px;
如果您希望背景颜色与字母的高度相同,则只需行高。 19px 将允许使用大写字母 - 如果您希望它只是小写字母,您可以将其缩小,例如 13px。
关于html - CSS如何使文本对齐背景颜色顶线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12101878/