function getFontSize() {
var baseFontSize = 100;
var baseWidth = 750;
var minWidth = 320;
var clientWidth = window.innerWidth;
var innerWidth = Math.max(Math.min(clientWidth, baseWidth), minWidth);
var rem = clientWidth / (baseWidth / baseFontSize);
if (clientWidth > baseWidth) {
rem = 100
}
if (clientWidth < minWidth) {
rem = minWidth / (baseWidth / baseFontSize);
}
document.querySelector('html').style.fontSize = rem + 'px';
}
(function(doc, win) {
getFontSize();
window.onresize = function() {
getFontSize();
}
})(document, window);
网友评论