rem的运用

Utils.adaptive = function () {
   !function () {
     function e() {
     var e = document.documentElement.clientWidth, t = document.querySelector("html"), f = (e>750?750:e) / 20;
     window.fontSize = f;
     t.style.fontSize = f + "px"
  }

    e(), window.addEventListener("resize", e);
  }();
};

放在公共的js代码中,在本页面调用时,直接用Utils.adaptive();调用就好了。

原文地址:https://www.cnblogs.com/hzc961850/p/7716376.html