动态设置font-size
针对以rem为单位的项目,计算html的font-size ,
// 计算html的font-size (function(){
function resizeBaseFontSize(){
var rootHtml = document.documentElement,
deviceWidth = rootHtml.clientWidth;
if(deviceWidth > 640){
deviceWidth = 640;
}
rootHtml.style.fontSize = deviceWidth / 7.5 + "px";
} resizeBaseFontSize(); window.addEventListener("resize", resizeBaseFontSize, false); window.addEventListener("orientationchange", resizeBaseFontSize, false); })();