//设置跟元素字体大小,配合rem做屏幕适配
```
(
function(doc,win){
let docEl=doc.documentElement;
resizeEvt="orientationChange" in window ? 'orientationchange' :'resize';
recalc=function(){
let clientWidth=docEl.clientWidth;
if(!clientWidth) return;
window.font=docEl.style.fontSize=parseInt(30*(clientWidth/750)) + 'px';
};
if(!doc.addEventListener) return;
win.addEventListener(resizeEvt,recalc,false);
doc.addEventListener('DOMContentLoaded',recalc,false);
}
)(document,window);
```
网友评论