<script>
(function () {
function w() {
var r = document.documentElement;
var a = r.getBoundingClientRect().width; //获取当前设备的宽度
if (a >= 1920) {
//720不固定,根据设计稿的宽度定
a = 1920;
}
rem = a / 192;
r.style.fontSize = rem + "px";
}
w();
window.addEventListener(
"resize",
function () {
//监听横竖屏切换
w();
},
false
);
})();
</script>
rem布局适配
于 2023-02-13 14:30:03 首次发布