1 // JavaScript Document 2 (function (doc, win) { 3 var docEl = doc.documentElement, 4 resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘, 5 recalc = function () { 6 var clientWidth = docEl.clientWidth; //获取设备尺寸 7 if (!clientWidth) return; 8 if(clientWidth>=750){ //设计稿宽度 9 docEl.style.fontSize = ‘100px‘; 10 }else{ 11 docEl.style.fontSize = 100 * (clientWidth / 750) + ‘px‘; 12 } 13 }; 14 if (!doc.addEventListener) return; 15 win.addEventListener(resizeEvt, recalc, false); //绑定事件 16 doc.addEventListener(‘DOMContentLoaded‘, recalc, false); 17 18 })(document, window);