根据窗口大小动态计算字体大小
function computed() {
let HTML = document.documentElement,
deviceW = HTML.clientWidth,
designW = 750,
ratio = deviceW / designW * 100;
if (deviceW >= 410) ratio = 410 / designW * 100;
HTML.style.fontSize = ratio + 'px';
}
computed();
window.addEventListener('resize', computed);
网友评论