1. 程式人生 > >移動端字型單位該使用px還是rem?

移動端字型單位該使用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/)--