function rem(win, doc){ function setFontSize() { var winWidth = window.innerWidth; var size = (winWidth / 640) * 100; doc.documentElement.style.fontSize = (size < 100 ? size : 100) + 'px' ; } var evt = 'onorientationchange' in win ? 'orientationchange' : 'resize'; var timer = null; win.addEventListener(evt, function () { clearTimeout(timer); timer = setTimeout(setFontSize, 300); }, false); win.addEventListener("pageshow", function(e) { if (e.persisted) { clearTimeout(timer); timer = setTimeout(setFontSize, 300); } }, false); setFontSize(); console.log('page loaded') }; window.onload = rem(window, document);目前这样写还是有问题,rem的布局没生效
1 回答
慕慕森
TA贡献1856条经验 获得超17个赞
$(window).on("resize",function(){
$("html").css("fontSize",$(window).width()/6.4);
}).resize();
添加回答
举报
0/150
提交
取消