移动端使用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;");
})();

猜你喜欢

转载自www.cnblogs.com/jongsuk0214/p/9008974.html