移动端适配之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>

猜你喜欢

转载自www.cnblogs.com/happyty/p/9655007.html