rem计算
1 (function (win, doc) { 2 if (!win.addEventListener) return; 3 var html = document.documentElement; 4 function setFont() { 5 var html = document.documentElement; 6 var k = 720; 7 html.style.fontSize = html.clientWidth / k * 100 + "px"; 8 } 9 setFont(); 10 setTimeout(function () { 11 setFont(); 12 }, 300); 13 doc.addEventListener('DOMContentLoaded', setFont, false); 14 win.addEventListener('resize', setFont, false); 15 win.addEventListener('load', setFont, false); 16 })(window, document);