H5页面尺寸兼容rem

//计算根节点HTML的字体大小
function resizeRoot(){
var deviceWidth = document.documentElement.clientWidth,
num = 750,
num1 = num / 100;
if(deviceWidth > num){
deviceWidth = num;
}
document.documentElement.style.fontSize = deviceWidth / num1 + "px";
}
//根节点HTML的字体大小初始化
resizeRoot();

window.onresize = function(){
resizeRoot();
};

posted @ 2020-07-29 17:10  百思得其姐  阅读(117)  评论(0编辑  收藏  举报