h5 网页适配

function remInit (){
    window.onresize = r;
    function r(resizeNum) {
        //核心适配代码
        var winW = window.innerWidth;
        // document.getElementsByTagName("html")[0].style.fontSize = winW * 0.15625 + "px";  //设计稿640
        document.getElementsByTagName("html")[0].style.fontSize = winW * 0.13333333333 + "px"; //设计稿750
        //核心适配代码
        if (winW > window.screen.width && resizeNum <= 10) {
            setTimeout(function() {
                r(++resizeNum)
            }, 100);
        } else {
            document.getElementsByTagName("body")[0].style.opacity = 1;
        }
    }
    setTimeout(function() {
        r(0);
    }, 100);
}

 

posted @ 2019-08-16 10:31  老北京(LBJ)  阅读(189)  评论(0编辑  收藏  举报