移动端rem.js
文章目录
function remRefresh() {
let clientWidth = document.documentElement.clientWidth;
// 将屏幕分成10等份
let rem = clientWidth / 10;
document.documentElement.style.fontSize = rem + 'px'
document.body.style.fontSize = '12px'
}
window.addEventListener('pageshow', () => {
remRefresh()
})
// 函数防抖
let timeoutId;
window.addEventListener('resize', () => {
timeoutId && clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
remRefresh()
}, 300)
})
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册⭐️ Admin快速开发: https://show.cool-admin.com/
赞 0⭐️ 官方文档: https://cool-js.com
赞 0⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld
赞 0