html-size-calculation.js 515 B

12345678910111213
  1. (function (doc, win) {
  2. var docEl = doc.documentElement,
  3. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  4. recalc = function () {
  5. var clientWidth = docEl.clientWidth;
  6. if (!clientWidth) return;
  7. docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';
  8. };
  9. if (!doc.addEventListener) return;
  10. win.addEventListener(resizeEvt, recalc, false);
  11. doc.addEventListener('DOMContentLoaded', recalc, false);
  12. })(document, window);