摘自w3c
em unit
Equal to the computed value of the ‘font-size’ property of the element on which it is used.
h1 { line-height: 1.2em }
means that the line height of h1 elements will be 20% greater than the font size of h1 element. On the other hand:
h1 { font-size: 1.2em }
means that the font size of h1 elements will be 20% greater than the computed font size inherited by h1 elements.
rem unit
Equal to the computed value of ‘font-size’ on the root element.
When specified on the ‘font-size’ property of the root element, the ‘rem’ units refer to the property’s initial value.
本文详细解释了CSS中EM和REM单位的含义及其使用方法。EM单位等于元素本身计算后的字体大小,而REM单位则等于根元素的计算后字体大小。通过具体示例展示了这两种单位如何应用于字体大小和行高设置。
497

被折叠的 条评论
为什么被折叠?



