js rem的换算 适配各个屏幕

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(function(){
            function computed(){
                let winW = document.documentElement.clientWidth,
                    desW = 750,
                    root = 100,
                    ratio = winW / desW * root;
                if(winW > desW){
                    document.documentElement.style.fontSize = root + 'px';
                    return
                }
                document.documentElement.style.fontSize = ratio + 'px';
            }
            computed();
            window.addEventListener('resize',computed);
        })();

  

posted @   酸suan  阅读(105)  评论(1编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示