//css
html{
font-size:10px;
}
元素{
font-size:1.2rem;
}
//js
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () { var clientWidth = docEl.clientWidth; var clientHeight = docEl.clientHeight; if (!clientWidth) return; if(window.orientation === 0 || window.orientation === 180){//判断竖屏 docEl.style.fontSize = 10 * (clientWidth / 320) + 'px'; }else if(window.orientation === 90 || window.orientation === -90){//判断横屏 docEl.style.fontSize = 10 * (clientHeight / 320) + 'px'; } }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); })(document, window);