rem ,em在實際中的應用


rem其實就是以html文檔的根元素的的font-size為基准倍數, 在pc端中默認是12px

1rem = 12px *1  2rem = 12px *2

在實際應用中,要根據的原型來處理,基准備注是根據documentElemnt.style.fontSize為准的,

<script>
        document.documentElement.style.fontSize=20*document.documentElement.clientWidth/320+'px';
        window.onresize=function(){
            document.documentElement.style.fontSize=20*document.documentElement.clientWidth/320+'px';
        };
</script>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM