作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试删除添加到字体顶部/底部的边距。
<div id="wrapper">
<span id="text">Text</span>
</div>
#wrapper{
width: 200px;
height: 200px;
Border: 1px solid black;
margin: 0px;
padding: 0px;
}
#text{
background: red;
font-size: 40px;
line-height: 30px;
padding: 0px;
margin-top: 0px;
margin-left: 5px;
}
fiddle
https://jsfiddle.net/fsmje7Ly/1/
如何将红色背景增加到字体高度?
我怎样才能从字体中删除顶部/底部边距?
我试过使用 line-height: 30px;
最佳答案
尝试下面的代码你会得到想要的输出。
#wrapper{
width: 200px;
height: 200px;
Border: 1px solid black;
margin: 0px;
padding: 0px;
}
#text{
background: red;
font-size: 40px;
line-height: 30px;
padding: 0px;
margin-top: 0px;
margin-left: 0;
display:inline-block;
}
关于html - 如何增加字体的上边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46807409/
我是一名优秀的程序员,十分优秀!