(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = document.body.clientWidth;
if (!clientWidth)
return;
docEl.style.fontSize = 100 * (clientWidth / 360) + 'px';
};
if (!doc.addEventListener)
return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
或
document.documentElement.style.fontSize=20*document.documentElement.clientWidth/640+'px';
设计图字体除以20、640参数随设计图宽度做相应变化