美文网首页
移动端适配设置rem

移动端适配设置rem

作者: 德德de_前端攻城狮 | 来源:发表于2021-02-24 09:50 被阅读0次
  function rem() {
        var t = 100,
            o = 750,
            e = document.documentElement.clientWidth || window.innerWidth,
            n = Math.max(Math.min(e, 480), 320),
            h = 50;
        320 >= n && (h = Math.floor(n / o * t * .99)), n > 320 && 362 >= n && (h = Math.floor(n / o * t * 1)), n > 362 && 375 >=
            n && (h = Math.floor(n / o * t * 1)), n > 375 && (h = Math.floor(n / o * t * .97)), document.querySelector("html").style
            .fontSize = h + "px"
    };
    rem();
    window.onresize = function() {
        rem();
    }

相关文章

网友评论

      本文标题:移动端适配设置rem

      本文链接:https://www.haomeiwen.com/subject/hqvpeftx.html