简体   繁体   English

在根级别使用时,rems 和 ems 是否等效?

[英]Are rems and ems equivalent when used at root level?

From this answer I see what's the definition of rem in the spec:这个答案中,我看到规范中rem的定义是什么:

rem unit单位

Equal to the computed value of font-size on the root element.等于根元素上font-size的计算值。 When specified in the font-size property of the root element, or in a document with no root element, 1rem is equal to the initial value of the font-size property.当在根元素的font-size属性中指定时,或在没有根元素的文档中, 1rem等于font-size属性的初始值。

And the definition of em is: em的定义是:

em unit单位

Equal to the computed value of the font-size property of the element on which it is used.等于使用它的元素的font-size属性的计算值。

To me this implies that 1em == 1rem by definition when used at :root .对我来说,这意味着1em == 1rem:root使用时的定义。

Am I correct?我对么?

Yes是的

 :root { font-size:40px; border-top: 1rem solid red; border-bottom:1em solid green; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM