移动端适配

        // 适配100倍 1rem = 100px
        fnResize();
        window.onresize = function() {
            fnResize();
            window.addEventListener("resize", fnResize);
        };

        function fnResize() {
            let devWidth = document.documentElement.clientWidth || window.innerWidth;
            if (devWidth >= 750) {
                devWidth = 750;
            }
            if (devWidth <= 320) {
                devWidth = 320;
            }
            document.documentElement.style.fontSize = devWidth / 3.75 + "px";
        }

375设计稿,用的3.75

posted @ 2021-06-21 09:18  小夜猫啊  阅读(39)  评论(0编辑  收藏  举报