document.getElementsByTagName("html")[0].style.fontSize=document.documentElement.clientWidth/15+"px";
window.onresize = function(){
document.getElementsByTagName("html")[0].style.fontSize=document.documentElement.clientWidth/15+"px";
}
这是根据 浏览器窗口宽度对html的fontSize 进行赋值 假设 浏览器页面宽度是150px 那么html的font-size就是10px
1rem=当前根元素(html)的font-size的大小 所以说当浏览器宽度为150px时 1rem为10px