//设置html的font-size
var eventutil = {
addhandler: function(element, type, handler){
if (element.addeventlistener){
element.addeventlistener(type, handler, false);
} else if (element.attachevent){
element.attachevent("on" + type, handler);
} else {
element["on" + type] = handler;
}
}
};
function change() {
var window_w = document.documentelement.clientwidth;
window_w = window_w > 640 ? 640 : window_w;
//如果移动端设计稿是1920px的,window_w就除以19.2
document.documentelement.style.fontsize = window_w / 6.4 + 'px';
}
change();
//检测手机横竖屏
eventutil.addhandler(window, 'orientationchange', change);
eventutil.addhandler(window, 'resize', change);
//屏幕尺寸变化
// window.addeventlistener('orientationchange',change,false);
window.addeventlistener('resize',change,false);