[英]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 thefont-size
property of the root element, or in a document with no root element,1rem
is equal to the initial value of thefont-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.