(function (doc, win) {
var docEle = doc.documentElement,
resizeEvent = 'orientationchange' in window ? 'orientationchange' : 'resize';
var recalCulate = function () {
var width = docEle.clientWidth;
docEle.style.fontSize = 40 * (width / 1080) + 'px';
};
recalCulate();
if (!doc.addEventListener) return;
win.addEventListener(resizeEvent, recalCulate, false);
})(document, window);
注:
docEle.style.fontSize = 40 * (width / 1080) + 'px';// 这里的40转换为rem时需要除以2
比如:font-size = 16px,转换为rem的值为0.8rem(16/(40/2)=0.8)