移动端字体单位该使用px还是rem?

对于只需要适配少部分手机设备,分辨率对页面影响不大的,使用px即可,

对于需要适配各种移动设备,使用rem,例如只需要适配iPhone和iPad等分辨率差别比较挺大的设备。

rem配置参考,适合视觉稿宽度为640px的:

< meta  content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
html{font-size:10px}
@media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}}
@media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}}
@media screen and (min-width:415px) and (max-width:639px){html{font-size:15px}}
@media screen and (min-width:640px) and (max-width:719px){html{font-size:20px}}
@media screen and (min-width:720px) and (max-width:749px){html{font-size:22.5px}}
@media screen and (min-width:750px) and (max-width:799px){html{font-size:23.5px}}
@media screen and (min-width:800px){html{font-size:25px}}

来自博客园--下雨天的太阳(http://www.cnblogs.com/doomjx/)--

猜你喜欢

转载自blog.csdn.net/weixin_42213918/article/details/80476600