没有单位的行高 [英] Line-height without units
问题描述
我看到人们使用线高而没有指定单位,例如: line-height:1.5;
I saw people using line height without specifying a unit, like this: line-height: 1.5;
数字代表什么?我猜这是一个比率,所以是 em
?
What does the number represents? I'm guessing it's a ratio so is it like em
?
推荐答案
line-height
@ Mozilla开发人员网络有一个非常好的解释(和示例),与 line-height
CSS规格。
line-height
@ Mozilla Developer Network has a very good explanation (and examples) which is a easier to understand compared to the line-height
CSS specification.
line-height
可以具有以下某种方式指定的值
line-height
can have the value specified in one of the following ways
line-height: normal | <number> | <length> | <percentage>
在您的情况下,您使用的是< number>
其描述为:
In your case, you are using a <number>
which is described as:
使用的值是无单位
< number>
乘以元素的字体大小。计算的值与指定的< number>
相同。在大多数情况下,这是设置行高的首选方法,在继承情况下没有意外结果。
The used value is this unitless
<number>
multiplied by the element's font size. The computed value is the same as the specified<number>
. In most cases this is the preferred way to set line-height with no unexpected results in case of inheritance.
这篇关于没有单位的行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!