rem的用法

rem 是css3中的屬性,ie8下不兼容。
rem是相對於根元素<html>  這就意味着咱們只須要在 根目錄加入如下css代碼。 默認單位爲16px,咱們須要在用rem的時候除以16  就是rem的值。  好比字體是20px, css

 20÷16 = 1.25rem便可。html

@media only screen and (max-width: 320px) {
    html {
        font-size: 16px;
    }
}

@media only screen and (min-width: 321px) and (max-width: 360px) {
    html {
        font-size: 18px;
    }
}

@media only screen and (min-width: 361px) and (max-width: 375px) {
    html {
        font-size: 18.75px;
    }
}
@media only screen and (min-width: 376px) and (max-width: 384px) {
    html {
        font-size: 19px;
    }
}

@media only screen and (min-width: 385px) and (max-width: 413px) {
    html {
        font-size: 19px;
    }
}

@media only screen and (min-width: 414px) and (max-width: 480px) {
    html {
        font-size: 20.7px;
    }
}

@media only screen and (min-width: 481px) and (max-width: 540px) {
    html {
        font-size: 27px;
    }
}

來源:https://lufeng.info/ 前端

 

推薦前端交流羣: 羣號:339840649; 羣名稱:JS、VUE 工程與技術 歡迎加入~
點擊加入:html5/css3/js/jq/nodejs/div
html5

掃碼加入:node

相關文章
相關標籤/搜索