标签:change lob 设置 htm nts window func turn fonts
var Global={ init:function() { this.htmlFontSize(); }, //设置根元素的font-size htmlFontSize:function(){ var doc = document; var win = window; function initFontSize(){ var docEl = doc.documentElement, resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘, recalc = function(){ var clientWidth = docEl.clientWidth; if(!clientWidth) return; if(clientWidth>640){ clientWidth=640; } fontSizeRate = (clientWidth / 320); var baseFontSize = 50*fontSizeRate; docEl.style.fontSize = baseFontSize + ‘px‘; } recalc(); if(!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener(‘DOMContentLoaded‘, recalc,false); } initFontSize(); } }; Global.init();
标签:change lob 设置 htm nts window func turn fonts
原文地址:https://www.cnblogs.com/ladybug7/p/12943481.html