rem2.js 555 B

1234567891011121314151617181920
  1. (function adaptation() {
  2. var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
  3. function resize() {
  4. var html = document.documentElement;
  5. var wd = html.clientWidth;
  6. if (wd >= 750) {
  7. wd = 750
  8. }
  9. html.style.fontSize = wd / 7.5 + 'px';
  10. }
  11. resize();
  12. var timer;
  13. window.addEventListener(resizeEvt, function () {
  14. timer && clearTimeout(timer);
  15. timer = setTimeout(resize, 300)
  16. });
  17. document.addEventListener('DOMContentLoaded', resize);
  18. })()