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

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

问题描述

所以,回到当天,更喜欢使用EMs到像素的字体大小,因为EMs缩放IE6,而像素没有。然而,这些天,每个现代浏览器都能够正确缩放像素大小的字体。 EMs的其他优点是它级联,而像素不。



也就是说,如果一个人为现代浏览器做网络开发,并且绝对想要级联字体大小,像素是首选吗?



我想想如果使用像素的字体大小而不是EM有任何其他缺点。谢谢!

解决方案

虽然每个现代浏览器都能够使用px缩放文本,



尝试使用缩放功能在IE8中缩放文本,绝对精确。


  1. IE8 - 缩放(缩放):使用正式文字大小修改器缩放(页面 - >文字大小 - >最大)

  2. Google Chrome 10测试版 - 缩放,无标度

我使用的几个官方正文使用正式文本大小修改器作为其用户/组设置管理的一部分。为用户设置帐户时,通常会使用此设置对其进行预配置。我不知道他们是否必须设置它...但对我来说,EM仍然是可取的,因为PX不会扩展到任何地方。



最后,几个

>


  • 不要在pt中指定字体大小,或为屏幕样式表指定其他绝对长度单位。它们在不同平台上呈现不一致,并且无法由用户代理(例如浏览器)调整大小。

  • 使用相对长度单位(例如百分比或(更好的))
  • $ b,使用此类单位在具有固定和已知物理属性$ b

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


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.

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

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

解决方案

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.

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 - Zoom, no scale
  2. Firefox 4, beta 12 - Zoom, no scale
  3. Google Chrome 10 beta - Zoom, no scale

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.

Finally, a few words from the W3C.

Units: avoid absolute length units for screen display

  • Do not specify the font-size in pt, or other absolute length units for screen stylesheets. They render inconsistently across platforms and can't be resized by the User Agent (e.g browser). Keep the usage of such units for styling on media with fixed and known physical properties (e.g print).
  • Use relative length units such as percent or (better) em

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

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

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