码迷,mamicode.com
首页 > 移动开发 > 详细

移动端适配 rem 设置

时间:2018-08-31 15:47:58      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:移动   doc   refresh   nbsp   rem   time   element   nts   on()   

    refresh();
    window.onresize = function(){
      setTimeout(function(){
        refresh();
      },10)
    };
    function refresh() {
      let deviceWidth = document.documentElement.clientWidth;
      if (deviceWidth > 1200) {
        document.documentElement.style.fontSize = 1200 / 12 + "px";
      } else {
        document.documentElement.style.fontSize = deviceWidth / 7.5 + "px";
        console.log(deviceWidth / 7.5+ "px");
      }
    }

移动端适配 rem 设置

标签:移动   doc   refresh   nbsp   rem   time   element   nts   on()   

原文地址:https://www.cnblogs.com/shouzi/p/9565897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!