12345678910111213141516171819 |
- (function(doc, win) {
- var docEl = doc.documentElement,
- resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
- recalc = function() {
- var fontSize = RootNodeFontSize();
- if(fontSize == 0) return;
- docEl.style.fontSize = fontSize + 'px';
- };
- if(!doc.addEventListener) return;
- win.addEventListener(resizeEvt, recalc, false);
- doc.addEventListener('DOMContentLoaded', recalc, false);
- })(document, window);
- //获取根节点的font-size
- function RootNodeFontSize(){
- var clientWidth = document.documentElement.clientWidth;
- if(!clientWidth) return 0;
- if(clientWidth > 750) clientWidth = 750;
- return clientWidth / 7.5;
- }
|