天天看点

em是否到了退出的时候

今天看到 YUI CSS 框架中的时,看到用了其用来表示宽度的时候,很多地方都用了 em,在调整字体大小的时候,用了百分比。官方的说法是这样的:

Always use percentages as the units because they render more consistently than ems, and because they allow user-initiated resizing (unlike pixels).

在两年前的时候,我们都知道 em 优于 px 的地方在于能够允许用户调整字体的大小(特别是在IE下)。随着浏览器升级大战,现在多数的浏览器都能够支持 px 和 em 字体的缩放了,那么,我们还有必要在使用 em 么?

特别是像YUI CSS这样,使用 em 来定义页面的尺寸,是否不如用 px 来的直观和精确呢?

#doc, #doc2, #doc3, #doc4, .yui-t1, .yui-t2, .yui-t3, .yui-t4, .yui-t5, .yui-t6, .yui-t7 {     margin:auto;     text-align:left;     width:57.69em; *width:56.25em; } #doc2 {     width:73.076em; *width:71.25em; #doc3 {     margin:auto 10px;     width:auto; #doc4 {     width:74.923em; *width:73.05em;

在段落中,定义缩进两字字的时候使用 em 是很方便的,但是像这样 width:12.30769em; 来定义尺寸的,我想平时没有人会这么写吧。

参考资料