天天看點

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; 來定義尺寸的,我想平時沒有人會這麼寫吧。

參考資料