标签:event listener pre content 设计 window listen document element
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘, recalc = function () { var clientWidth = docEl.clientWidth; if (!clientWidth) return; if(clientWidth>=640){ docEl.style.fontSize = ‘100px‘; }else{ docEl.style.fontSize = 100 * (clientWidth / 640) + ‘px‘; } }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener(‘DOMContentLoaded‘, recalc, false); })(document, window);
宽640的设计稿,这样设置后,10px相当于0.1rem 100px相当于1rem 1:100的关系
标签:event listener pre content 设计 window listen document element
原文地址:https://www.cnblogs.com/wuchenggong/p/9354893.html