移动端rem适配方案

方案1
<script>

fnResize()
window.onresize = function () {
  fnResize()
}
function fnResize() {
  var deviceWidth = document.documentElement.clientWidth || window.innerWidth
  if (deviceWidth >= 750) {
    deviceWidth = 750
  }
  if (deviceWidth <= 320) {
    deviceWidth = 320
  }
  document.documentElement.style.fontSize = (deviceWidth / 7.5 * 2) + 'px'
}

</script>
方案2
淘宝移动端适配方案
https://github.com/amfe/lib-flexible

评论

暂无评论