字体大小:EMs vs Pixels...在2011年,应该使用哪一个? [英] Font sizes: EMs vs Pixels... in 2011, which one should be used?

查看:11
本文介绍了字体大小:EMs vs Pixels...在2011年,应该使用哪一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在过去,人们更喜欢使用 EM 到像素来确定字体大小,因为 EM 可以使用 IE6 进行缩放,而像素则没有.然而,如今,每个现代浏览器都能够正确缩放像素大小的字体.EMs 的另一个优点是它级联,而像素则没有.

So, back in the day, it was much preferred to use EMs to pixels for font size because EMs scaled with IE6 whereas pixels did not. However, these days, every modern browser is able to scale pixel sized font correctly. EMs other advantage was that it cascades, whereas pixels do not.

也就是说,如果您正在为现代浏览器进行 Web 开发并且绝对想要级联字体大小,那么像素会更受欢迎吗?

That said, if one were doing web development for modern browsers and absolutely did NOT want cascading font sizes, would pixels be preferred?

我想考虑使用像素代替 EM 字体大小是否还有其他缺点.谢谢!

I'm trying to think if there are any other drawbacks to using pixels for font size instead of EMs. Thanks!

推荐答案

虽然每个现代浏览器都能够缩放使用 px 大小的文本,但它们不能全部使用 px 缩放文本,这仍然取决于浏览器.

While every modern browser is able to zoom with text sized using px, they can't all scale text sized using px, it still depends on the browser.

尝试使用缩放在 IE8 中缩放"文本,绝对没问题.使用官方文本大小修饰符(页面 -> 文本大小 -> 最大)缩放,但不起作用.

Try 'scaling' text in IE8 using zoom, absolutely fine. Scale using the official text size modifier (page -> text size -> largest), and it doesn't work.

  1. IE8 - 缩放,无比例
  2. Firefox 4, beta 12 - 缩放,无缩放
  3. Google Chrome 10 测试版 - 缩放,无缩放

与我合作的几个官方机构使用官方文本大小修饰符作为其用户/组设置管理的一部分.为用户设置帐户时,通常会使用此设置对其进行预配置.我不知道他们是否必须将它设置在那里......但对我来说,EM 仍然更可取,因为 PX 不能随处扩展.

Several official bodies that I work with use the official text size modifier as part of their user/group settings management. When accounts are set up for users, they're often pre-configured using this setting. I don't know if they have to set it there ... but for me, EMs are still preferable because PX doesn't scale everywhere.

最后,来自 W3C 的几句话.

Finally, a few words from the W3C.

Units:避免使用绝对长度单位屏幕显示

  • 不要为屏幕样式表指定字体大小(pt)或其他绝对长度单位.它们跨平台呈现不一致,并且无法由用户代理(例如浏览器)调整大小.保留使用此类单位在具有固定和已知物理属性的媒体(例如印刷品)上进行样式设置.
  • 使用相对长度单位,例如百分比或(更好的)em

ref: http://www.w3.org/QA/Tips/font-尺寸

这篇关于字体大小:EMs vs Pixels...在2011年,应该使用哪一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆