web移动端CSS使用rem单位设置font-size自适应

:root {
font-size: 16px;
}

@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-device-pixel-ratio: 2) {
:root {
font-size: 18.75px;
}
}

@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (-webkit-device-pixel-ratio: 3) {
:root {
font-size: 20.7px;
}
}

@media screen and (min-width: 414px) {
:root {
font-size: 20.7px;
}
}

 

or

 

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}}

 

posted @ 2016-03-03 11:33  Silverdew  阅读(1122)  评论(0)    收藏  举报