<script>
function setRem() {
//ui给的宽度,默认iPhone SE
var ui_w = 375;
// 获取屏幕的宽度
var clientWidth = document.documentElement.clientWidth || document.body.clientWidth;
// 通过js动态改变html根节点字体大小
var html_ = document.getElementsByTagName('html')[0];
html_.style.fontSize = (clientWidth / ui_w) * 10 + 'px';
}
// window.onresize 浏览器被重置大小执行事件
window.onresize = setRem;
window.onload = setRem;
</script>
移动端 rem适配
猜你喜欢
转载自blog.csdn.net/weixin_59739381/article/details/130862409
今日推荐
周排行