Open richardmyu opened 5 years ago
;(function(doc, win) { const docEl = doc.documentElement const resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize' const recalc = function() { let clientWidth = docEl.clientWidth if (!clientWidth) { return } if (clientWidth >= 750) { docEl.style.fontSize = '100px' } else { docEl.style.fontSize = 100 * (clientWidth / 750) + 'px' } } if (!doc.addEventListener) { return } win.addEventListener(resizeEvt, recalc, false) doc.addEventListener('DOMContentLoaded', recalc, false) })(document, window)
参考:
1.移动端自适应布局解决方案——rem
2.DOMContentLoaded 与 load 的区别
3.你不知道的 DOMContentLoaded
参考:
1.移动端自适应布局解决方案——rem
2.DOMContentLoaded 与 load 的区别
3.你不知道的 DOMContentLoaded