js计算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);
})();

原文地址:https://www.cnblogs.com/zzwlong/p/7064604.html