//designSize为设计稿的尺寸(宽)
(function(doc, win, designSize) {
var docEl = document.documentElement,
devWidth = docEl.clientWidth > 1080 ? 1080 : docEl.clientWidth,
resizeEvt = ‘orientationchange’ in window ? ‘orientationchange’ : ‘onresize’, //判断横屏和窗口重置
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = devWidth / (designSize / 100) + ‘px’;
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener(‘DOMContentLoaded’, recalc, false);
})(document, window, 750);
版权声明:本文为Chengbin_Huang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。