style.js 1019 B

123456789101112131415161718192021222324252627282930
  1. // $(window).resize(function (){
  2. // let designSize = 1920; // 设计图尺寸
  3. // let html = document.documentElement;
  4. // let wW = html.clientWidth;// 窗口宽度
  5. // let rem = wW * 100 / designSize;
  6. // if (wW < 1200) {
  7. // wW = 1200
  8. // }
  9. // document.documentElement.style.fontSize = rem + 'px';
  10. // console.log('wW_______________________________________________',wW)
  11. // });
  12. (function(doc, win) {
  13. var docEl = doc.documentElement,
  14. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  15. recalc = function() {
  16. var clientWidth = docEl.clientWidth;
  17. if (!clientWidth) return;
  18. if (clientWidth < 1200) {
  19. clientWidth = 1200;
  20. }
  21. docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px';
  22. };
  23. if (!doc.addEventListener) return;
  24. win.addEventListener(resizeEvt, recalc, false);
  25. doc.addEventListener('DOMContentLoaded', recalc, false);
  26. })(document, window);