美文网首页
js 移动端px rem适配之rem.js

js 移动端px rem适配之rem.js

作者: Micro同学 | 来源:发表于2019-10-15 15:57 被阅读0次
function setRem() {
  let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth
  let htmlDom = document.getElementsByTagName('html')[0]
  htmlDom.style.fontSize = htmlWidth / 20 * 8 / 3 + 'px'
}
setRem()
window.onresize = function() {
  setRem()
}

在main.js引入这个js就好了

相关文章

网友评论

      本文标题:js 移动端px rem适配之rem.js

      本文链接:https://www.haomeiwen.com/subject/ujpsmctx.html