(function (doc, win) {
var docEle = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEle.clientWidth;
if (!clientWidth) return;
if(clientWidth>=750){
docEle.style.fontSize = '50px';
}else{
docEle.style.fontSize = 20 * (clientWidth / 375) + 'px';//这里是1rem=20px
}
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
网友评论