rem 响应式布局 设置

css 中给html 设置100px字体大小;

 在js中设置这样:  

(function(window) {


     let computedREM = function computedREM() {

     let winW = document.documentElement.clientWidth,

     desW = 640;
     

     if (winW >= desW) {
          document.documentElement.style.fontSize = '100px';
          return;
          }
     

       document.documentElement.style.fontSize = winW / desW * 100 + 'px';
};
computedREM(); 
            window.addEventListener('resize', computedREM);
})(window);

posted @ 2020-08-19 14:20  谎称  阅读(63)  评论(0)    收藏  举报