本文共--字 阅读约--分钟 | 浏览: -- Last Updated: 2021-07-03
(function (doc, win) {
var docEl = doc.documentElement;
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
function recalc() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
if (clientWidth >= 750) {
docEl.style.fontSize = '100px';
}else{
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
}
};
recalc();
win.addEventListener(resizeEvt, recalc, false);
})(document, window);
最终,如果设计图取的是 300px, 就直接除以 100,为3rem;