手机布局rem方案(font-size:100px;)

(function(window, document) {
    var viewWidth = 720;
    var pick = viewWidth / 100;
    var mode = "resize";
    
    function change() {
        var view = document.documentElement.clientWidth || window.innerWidth;

        if(view >= 720) {
            document.getElementsByTagName('html')[0].style.fontSize = 100 + 'px';
            return;
        }
        document.getElementsByTagName('html')[0].style.fontSize = view / pick + 'px';
        console.log(document.getElementsByTagName('html')[0].style.fontSize)
    }
    window.addEventListener(mode, change, !1);
    window.document.addEventListener('DOMContentLoaded', change, !1);
})(window, document);

 

posted @ 2018-06-20 16:07  爱尚丽明  阅读(266)  评论(0编辑  收藏  举报