(function () {
var timer = null;
function scale() {
var html = document.documentElement;
var r = html.clientWidth / 1920;
html.style.fontSize = Math.ceil(r * 100) + 'px';
html.classList.add('responsive');
var s = html.clientWidth / html.clientHeight;
if (s < 1.5) {
html.classList.add('narrow');
} else {
html.classList.remove('narrow');
}
timer = null;
}
window.onresize = function () {
if (timer) clearTimeout(timer);
timer = setTimeout(scale, 100);
}
scale();
})();
// 2
new function() {
var _self = this;
_self.width = 750; // 设置默认最大宽度
_self.fontSize = 40; // 默认字体大小
if ((document.body && document.body.clientWidth>750)||window.screen.width>750) {
return;
}
_self.widthProportion = function() {
var p = (document.body && document.body.clientWidth || document.getElementsByTagName("html")[0].offsetWidth) / _self.width;
return p > 1 ? 1 : p < 0.5 ? 0.5 : p;
};
_self.changePage = function() {
document.getElementsByTagName("html")[0].setAttribute("style", "font-size:" + _self.widthProportion() * _self.fontSize + "px !important");
}
_self.changePage();
window.addEventListener('resize', function() {
_self.changePage();
}, false);
};
console