rem佈局js設定
阿新 • • 發佈:2018-12-23
;(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));