var html = document.getElementsByTagName("html")[0];
function getFontSize(){
var width=document.documentElement.clientWidth
||document.body.clientWidth+"px";
var fontSize=(100/750)*width;
if(width>=750){
fontSize="100";
}
return fontSize;
}
html.style.fontSize=getFontSize()+"px";
window.onresize=function(){
setTimeout(function(){
html.style.fontSize=getFontSize()+"px";
},100)
};
移动端REM适配
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240803130933255-1404888097.jpg)