function setRem() { let doc = document.documentElement let width = doc.getBoundingClientRect().width || window.innerWidth let rem = width / 7.5 doc.style.fontSize = rem + 'px' } window.addEventListener('load', function () {
setRem() // console.log(document.documentElement.style.fontSize) }, false) window.addEventListener('resize', function () { setRem() }, false);