初始化html font-size
(function () { var docEl = document.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () { var clientWidth = docEl.clientWidth; //这里是假设在640px宽度设计稿的情况下,1rem = 20px;可以根据实际需要修改 docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'; }; recalc(); if (!document.addEventListener) return; window.addEventListener(resizeEvt, recalc, false); })();