为什么不能减小此文本的行高? [英] Why can't I decrease the line-height of this text?

查看:92
本文介绍了为什么不能减小此文本的行高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://jsfiddle.net/mJxn4/



这很奇怪:我有几行文本包裹在< em> 标签中。不管我做什么,将 line-height 的值降低到17px以下没有任何效果。我可以碰到 line-height c> 大于17px,它会应用,但我不能得到它低于17px。 / p>

问题的CSS是:

  #others .item em {
font-size:13px;
line-height:17px;
}

尝试调整高度和高度,改变,你会看到我的意思。



为什么会这样?在CSS中的任何其他位置指定 line-height ,因此没有什么是覆盖它。这可能不是这样的,因为我在同一个选择器中调整 line-height 上下,因此它不会

解决方案

因为 em 标签是内联的,其行高不能低于其父 div



例如,如果将父对象的line-height设置为10px,那么您也可以将 em 标签的行高减小到10px。


http://jsfiddle.net/mJxn4/

This is very odd: I have a few lines of text wrapped in an <em> tag. No matter what I do, lowering the value for line-height below 17px has no effect. I can bump the line-height up to greater than 17px and it'll apply, but I can't get it lower than 17px.

The CSS in question is:

#others .item em {
    font-size: 13px;
    line-height: 17px;
}

Try adjusting the line height both higher and lower and run the updated fiddle after each change, and you'll see what I mean.

Why would this be? No line-height is specified anywhere else in the CSS, so nothing is overriding it. That couldn't be the case anyway because I'm adjusting the line-height up and down within the same selector, so it doesn't make sense that a higher value would apply, but a lower value would get overridden.

解决方案

Because the em tag is inline and its line-height cannot be lower than its parent div.

For example, if you set the line-height of the parent to 10px, then you would be able to decrease the line-height of em tag to 10px as well.

这篇关于为什么不能减小此文本的行高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆