(function(){ function computed(){ let winW = document.documentElement.clientWidth, desW = 750, root = 100, ratio = winW / desW * root; if(winW > desW){ document.documentElement.style.fontSize = root + 'px'; return } document.documentElement.style.fontSize = ratio + 'px'; } computed(); window.addEventListener('resize',computed); })();