css3 - css rem 字体问题
PHP中文网
PHP中文网 2017-04-17 11:07:58
0
7
679

html {font-size: 62.5%;}
body {font-size: 1.4rem;}
这样式设置以后 1rem=10px; 1.4rem=14px;2rem=20px 但是在谷歌浏览器的和模型下是 1rem=12px

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(7)
黄舟

Please refer to http://techably.com/chrome-font-size-bug-fix/11996/
and http://stackoverflow.com/questions/20099844/chrome-not-respecting-rem-font-size-on-body-tag

伊谢尔伦

My own solution is a bit convoluted, you can refer to:
http://codepen.io/feilong/pen/YPpror

黄舟

Because the minimum font size of chrome and other mainstream browsers is 12px by default.
html {font-size: 62.5%;} is actually not set to 10px

伊谢尔伦

The reason is that chrome does not support 10px fonts.
Therefore, even if you set a 10px font, Google Chrome silently changes it to 12px for you.
The solution is to set the font size of the HTML to 50px, which is 312.5% ​​when converted into a percentage. This is how Meituan’s touch screen h5 page is handled.
It's much easier to calculate this way.
Of course, you can also set it to 20px, which is easy to calculate.
It is best to use css pre-compiled processor to save calculation.

Peter_Zhu

It is better to set html{font-size:62.5%;font-size:16px;font-size:1rem;}

左手右手慢动作

It’s best not to set it to something like 10px or 62.5%, you’d better make sure the font size set on the html is no less than 12px

迷茫

The minimum font size for Google Chrome is 12px.
Regarding the setting of fonts on the mobile terminal, it is not recommended to use rem units. The calculated font-size will appear as an odd number like 23. The method used by Taobao is to use media queries to set the font size based on the DPR value of the mobile phone. For specific methods, you can view related flexible articles.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template