我正在读关于rem
units in CSS3的文章,我有点困惑。如果你使用rem
,你会继续使用em
还是会取代它?
例如:
.selector {
margin-bottom:24px;
margin-bottom:2.4rem;
font-size:16px;
font-size:1.6rem;
}
或
.selector {
margin-bottom:24px;
margin-bottom:2.4em;
margin-bottom:2.4rem;
}
我只是想弄清楚,是rem
取代了em
,还是它只是另一个单位。
发布于 2011-11-12 09:05:20
Rem是根(html)元素的em大小。这意味着一旦定义了html元素的font-size,就可以定义与之相关的所有rem单位。
例如:
html { font-size: 62.5%; }
body { font-size: 1.4rem; } /* =14px */
h1 { font-size: 2.4rem; } /* =24px */
Safari5,Chrome,Firefox 3.6+,甚至is浏览器都支持Rem,但对于older browsers,你仍然需要使用em,percent或px。
发布于 2011-11-12 06:57:04
不,这是一个不同的单位。em
基于父元素的font-size,而rem
基于根font-size,我相信根font-size就是html
元素的font-size。
发布于 2011-11-12 09:48:00
Rem只是多了一个单位,它不会替换em,就像em不会替换像素一样。
https://stackoverflow.com/questions/8100940
复制相似问题