移动端使用rem

(function () {
    /****设置rem大小*****/
        //var deWidth = window.screen.width;
    var deWidth = window.innerWidth;  //视窗宽度
    var remPX = deWidth < 960 ? (deWidth / 18.75) : 40;  //若屏幕width大于960,html字体大小为40px
    document.querySelector("html").setAttribute("style", "font-size: " + remPX + "px;");
})();

 

posted @ 2018-05-08 16:18  靥放  阅读(111)  评论(0编辑  收藏  举报