我注意到您可以使用 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/