12345678910111213141516 |
- (function (doc, win) {
- var docEl = doc.documentElement,
- resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
- recalc = function () {
- var clientWidth = docEl.clientWidth;
- if (!clientWidth) return;
- // 最大宽度
- clientWidth = clientWidth > 640 ? 640 : clientWidth
- var fontSize = clientWidth / 7.5;
- docEl.style.fontSize = fontSize + 'px';
- };
- if (!doc.addEventListener) return;
- win.addEventListener(resizeEvt, recalc, false);
- doc.addEventListener('DOMContentLoaded', recalc, false);
- })(document, window);
|