We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
css3中新增单位 rem,那么如何区分和何时使用 rem 和 em 呢?
rem
em
相对于document根目录字体而言的相对单位,默认是相对于浏览器默认字体(16px),即:1rem = 16px。
相当于使用它的容器的字体而言,如果使用者的字体定义单位也是 em ,那么就有继承关系。
如:
|-- div1(font-size:12px;) |-- div2(font-size:2em;padding:3em;)
div2的padding = 3 x 2 x 12px = 72px。
既然都是相对单位,那么在不考虑浏览器兼容的情况下,如何选择使用这2个单位呢?
一般有2种情况可以考虑使用 em ,其余全部使用 rem。
哪两种呢?
当然以上两种只是比较典型的代表,只要是有严重依赖相关元素尺寸的,使用 em 比较合理而已。
如果大家看了以上文章,依然迷迷糊糊,说明你对这2个概念的基础只是掌握还不够,那么仔细阅读以下文章。
The text was updated successfully, but these errors were encountered:
sunmaobin
No branches or pull requests
css3中新增单位
rem
,那么如何区分和何时使用rem
和em
呢?一、定义
1、rem
相对于document根目录字体而言的相对单位,默认是相对于浏览器默认字体(16px),即:1rem = 16px。
2、em
相当于使用它的容器的字体而言,如果使用者的字体定义单位也是
em
,那么就有继承关系。如:
div2的padding = 3 x 2 x 12px = 72px。
既然都是相对单位,那么在不考虑浏览器兼容的情况下,如何选择使用这2个单位呢?
二、使用
一般有2种情况可以考虑使用
em
,其余全部使用rem
。哪两种呢?
当然以上两种只是比较典型的代表,只要是有严重依赖相关元素尺寸的,使用
em
比较合理而已。参考
如果大家看了以上文章,依然迷迷糊糊,说明你对这2个概念的基础只是掌握还不够,那么仔细阅读以下文章。
The text was updated successfully, but these errors were encountered: