html - em是如何计算的?

标签 html css fonts units-of-measurement

我注意到您可以使用 1em,它在不同的网站上看起来会有所不同。

em 与什么成比例?

  • 使用的字体?
  • 最大的字体大小?
  • 页面宽度/高度?

最佳答案

参见 http://w3schools.com/cssref/css_units.asp

1em is equal to the current font size. 2em means 2 times the size of the current font. E.g., if an element is displayed with a font of 12 pt, then '2em' is 24 pt. The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader uses

EM 相对于定义它的当前 元素。如果您使用相对大小(如 0.9em),它们会成倍增加并可能导致意外的尺寸。

现在,字体的默认大小不是浏览器之间的标准。将字体设置为特定像素单位时,IE(至少是较旧的 IE)存在问题。 good overview for font sizing can be found on A List Apart .

关于html - em是如何计算的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6887757/

相关文章:

html - 将一个 ul 放在一个 div 中(在一个 div 中),它本身在页面上居中

php - 如何正确提取get变量

html - CSS - 使列中的多个 div 回绕

ios - iOS 上的自定义字体始终使用 'regular' 样式

fonts - 可移植网络字体技术

html - 如何为 three.js 生成支持 Unicode 的字体文件?

javascript - 如何在一定高度后固定滚动 div 并在到达其他 div 后停止?

javascript - JS动画会覆盖自身而不是替换

html - 使用多个外部样式表还是尽可能少?优点和缺点

html - 当用户滚动时使一个导航栏变粘