Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 为什么用 em 而不是 px?
时间
或者
像素
%
我一直觉得px更好,但为什么人们使用 em?
px 是好的,如果你为单个浏览器设计,屏幕尺寸,字体等。这种方式你明确地设置页面元素的大小,并且没有例外是可能的。
如果您的网站在各种平台/浏览器中被查看,屏幕大小不同,某些字体不可用,用户更改浏览器字体大小等,那么使用抽象度量(例如 em 或 %)是一个好主意,因为使用它们,系统会尝试自动计算大小,从而使文本更难被截断。