// 移动端根据设备屏幕宽度动态设置html根元素的font-size,使用rem做单位 (function(){ var devicewidth = "", d = document.documentelement; window.onresize = setfont; setfont(); function setfont(){ devicewidth = math.min(750, window.innerwidth, d.clientwidth); d.style.fontsize = devicewidth / 7.5 + "px"; }; })();