em rem 相對單位:? 也可用于設置padding line-height等
em相對當前容器的默認字體設置
比如,所有瀏覽器默認字體都是16px,body{ font-size:62.5%}
以后即1em=10px; 1.2em=12px
在線轉換tool: http://pxtoem.com/
em(css2.0) rem(css3.0)
rem相對于頁根元素的字體大小,即 html 元素的字體大小
比如:html{font-size:16px;} 10rem=160px;
配合 使用media query 設置html的font-size;
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}}
轉載于:https://www.cnblogs.com/isdom/p/webclips036.html