fnResize(); window.onresize = function () { fnResize(); } function fnResize() { let designSize = 1920; let html = document.documentElement; let wW = html.clientWidth; let rem = wW * 10 / designSize; document.documentElement.style.fontSize = rem + 'px'; }