根据当前设备的宽度,动态计算出rem的换算比例,实现页面中元素的等比缩放

~function anonymous(window){

  //根据当前设备的宽度,动态计算出rem的换算比例,实现页面中元素的等比缩放

  let computedREM = function computedREM(){

    let winW = document.documentElement.clientWidth,

    desW = 640;

    if(winW>640){

      document.documentElement.style.fontSize = '100px';

      return;

    }

    document.documentElement.style.fontSize = winW/desW * 100 +'px';

  };

  computedEEM();

  window.addEventListener('resize',computedREM);

}(window);

posted on 2019-06-17 16:26  瑾然  阅读(173)  评论(0编辑  收藏  举报

导航