rem.js

!(function (doc, win) {
var el = doc.documentElement;//html
//resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';

//设置html的字体
function setSize() {
var w = el.clientWidth;
if (!w) return;
w=w>480?480:w;
w=w<320?320:w;
el.style.fontSize = (100 * (w / 1080)).toFixed(3) + 'px';
}
if (!doc.addEventListener) return;
setSize();
win.addEventListener('resize', setSize, false);
win.addEventListener('pageshow', function(e) {
if (e.persisted) {
setSize();
}
}, false);
})(document, window);

 

上一篇:Java常用类之Properties类


下一篇:8 个你不知道的 DOM 功能[每日前端夜话0x79]