textSize.js 483 B

123456789101112
  1. (function (doc, win) {
  2. // html
  3. var docEl = doc.documentElement,
  4. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () {
  5. var clientWidth = docEl.clientWidth;
  6. if (!clientWidth) return;
  7. clientWidth = (clientWidth > 768 ) ? 768 : clientWidth ; docEl.style.fontSize = 10 * (clientWidth / 375 ) + 'px';
  8. };
  9. if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false);
  10. recalc();
  11. })(document, window);
  12. /*移动端适应大小*/