[英]Font sizing with rem
html { font-size: 62.5%; }
body { font-size: 1.4rem; } /* =14px */
h1 { font-size: 2.4rem; } /* =24px */
Hey guys, I am trying to work out the calculation. 大家好,我正在尝试计算。 How do we get 14px for body and 24px for h1?
我们如何获得14像素的身体和24像素的h1?
When html
is given a font size as a percentage, it is calculated based on the font size preference set by the user in their browser options. 当给
html
字体大小作为百分比时,将根据用户在其浏览器选项中设置的字体大小首选项进行计算。 This is usually 16px as a "standard" across browsers, but of course it may vary based on the user's own settings. 在所有浏览器中,这通常是16像素作为“标准”,但是当然,它可能会根据用户自己的设置而有所不同。
62.5% of 16px is 10px, giving html
an absolute font size of 10px. 16px的62.5%为10px,因此
html
的绝对字体大小为10px。 From there, it should be easy to work out the sizes for body
and h1
. 从那里,应该很容易算出
body
和h1
的大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.