Anyone knows about it?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
From line-height
The used value is this unitless multiplied by the element's font size. The computed value is the same as the specified . In most cases this is is the preferred way to set line-height with no unexpected results in case of inheritance.
Relative to the font size of the element itself. The computed value is this percentage multiplied by the element's computed font size.
Short version:
line-height: 150%
is static,line-height: 1.5
is dynamic. The effect is more evident on inheriting elements. An example:HTML
This CSS
As opposed to this:
You may read more at the CSS2 specs page
Both are equivalent.line-height: 1.5
(without units) will mutiply the element's font size by1.5
to compute the line height.line-height: 150%
will take150%
of the element's computed font size to compute the line height, which is equivalent to multiply it by1.5
.Now let’s have a look at the question you asked.
I reproduced the two cases:
In 1), the parent's div's
line-height
is set to1.5
multiplied the div's actual font size. This property is inherited and recomputed for the childspan
because you changed its actual font size.In 2), the parent's div's
line-height
is set to150%
of the div's computed font size. Then the computed font size of thespan
is inherited from thediv
therefore150%
of this inherited computed font size leads to the same value.As @K Prime summed up, the take away is likely:
line-height: 150%
is static,line-height: 1.5
is dynamicReferences: