移动端适配之rem

<script>
        function setSize(){
            var a = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
            if(a > 750) {
                a = 750
            };
            document.documentElement.style.fontSize = a * 1 / 16 + "px";
            _htmlFontSize = a * 1 / 16;
        }
        setSize();

        window.onresize = function(){
            setSize();
        }
    </script>

 

posted @ 2018-09-16 08:48  绝版幸福  阅读(142)  评论(0编辑  收藏  举报