1. 程式人生 > >rem佈局js設定

rem佈局js設定

;(function(win,doc){
   function changeSize(){
       doc.documentElement.style.fontSize=50*doc.documentElement.clientWidth/320+'px'
   }////50是可變的
   changeSize();
   window.addEventListener('resize',changeSize,false)
})(window,document);
!(function(doc, win) {
   var docEle = doc.documentElement,
       evt = "onorientationchange"
in window ? "orientationchange" : "resize", fn = function() { var width = docEle.clientWidth; width && (docEle.style.fontSize = 50 * (width / 320) + "px"); }; //50是可變的 win.addEventListener(evt, fn, false); doc.addEventListener("DOMContentLoaded", fn, false
); }(document, window));