1 function qido() {
//获取手机屏幕真实宽度 2 var ss = document.documentElement.clientWidth; 3 aa = ss / 750; 4 var html = document.getElementsByTagName('html')[0]; 5 html.style.fontSize = aa * 10 + 'px'; 7 } 8 window.onload = function () { 9 qido(); 10 } 11 window.onresize = function () { 12 qido(); 13 }
ps:除以750是除以设计稿的宽度。设计稿中的1px换做其他屏幕中就是 其他手机屏幕尺寸的1/750,也就是1rem。
浙公网安备 33010602011771号