(function(doc, win) {
var docEl = doc.documentElement, //getElementById("luckDraw")
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
//if (!clientWidth) return;
if(clientWidth<600){
var width = clientWidth;
}else{
var width = 600;
}
docEl.style.fontSize = 20 * (width / 320) + 'px';
//宽与高度
//document.body.style.height = clientWidth * (900 / 1440) + "px"
};
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
var docEl = doc.documentElement, //getElementById("luckDraw")
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
//if (!clientWidth) return;
if(clientWidth<600){
var width = clientWidth;
}else{
var width = 600;
}
docEl.style.fontSize = 20 * (width / 320) + 'px';
//宽与高度
//document.body.style.height = clientWidth * (900 / 1440) + "px"
};
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
改变 html 标签的 font-size 的大小 来确定rem的值 , 上面是以苹果5手机 320宽度 为标准做的响应