移动端适配
<script type="text/javascript">
(function flexibleLite (window, document) {
var docEl = document.documentElement
// adjust body font size
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = 16 + 'px'
} else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
// set 1rem = viewWidth / 10
function setRemUnit () {
var rem = docEl.clientWidth / 375 * 100
docEl.style.fontSize = rem + 'px'
}
setRemUnit()
// reset rem unit on page resize
window.addEventListener('resize', setRemUnit)
window.addEventListener('pageshow', function (e) {
if (e.persisted) {
setRemUnit()
}
})
}(window, document))
</script>