<script> | |
(function (doc, win) { | |
var docEl = doc.documentElement, | |
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', | |
recalc = function () { | |
var clientWidth = docEl.clientWidth; | |
if (!clientWidth) return; | |
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px'; | |
}; | |
if (!doc.addEventListener) return; | |
win.addEventListener(resizeEvt, recalc, false); | |
doc.addEventListener('DOMContentLoaded', recalc, false); | |
})(document, window); | |
</script> |
rem为所有屏幕设置初始font-size
最新推荐文章于 2024-07-06 14:54:18 发布