//根据屏幕分辨率来确定rem基准以适应不同屏幕
(function() {
var availWidth = window.screen.width;
if (!availWidth) {
return 0;
}
availWidth = availWidth < 1280 ? 1280 : availWidth;
var fontSize = parseFloat(100 / 1280 * availWidth, 10).toFixed(2);
var root = document.documentElement || document.body;
root.style.fontSize = fontSize + 'px';
return fontSize;
})()
网友评论