不同宽度的手机,自适应html的字体大小,这样用rem非常方便
<script type="text/javascript"> (function(){ function a(h,g,b,e,c){ var f=h.documentElement,d="orientationchange" in window?"orientationchange":"resize"; var i=function(){ var j=f.clientWidth; if(j>=e&&j<=b){f.style.fontSize=c*(j/b)+"px"} else{if(j>=b){f.style.fontSize=c+"px"} else{if(j<=e){f.style.fontSize=c*(e/b)+"px"}}}}; g.addEventListener(d,i,false); h.addEventListener("DOMContentLoaded",i,false)} a(document,window,750,320,40) })(); </script>