; (function () {
// 1rem = 100px;
function w() {
const html = document.documentElement;
let a = html.getBoundingClientRect().width;
if (a > 750) {
a = 750;
}
const rem = a / 7.5;
// const scale = 0.8;
//有定位相关的
// const w = window.innerWidth, h = window.innerHeight
// html.style.transform = `scale( ${scale})`;
// html.style.width = (w / scale) + 'px';
// html.style.height = (h / scale) + 'px';
// html.style.marginLeft = (-(w / scale - w) / 2) + 'px'
// html.style.marginTop = (-(h / scale - h) / 2) + 'px'
//简单无定位页面
// html.style.zoom = scale
html.style.fontSize = rem + "px"
}
var t;
w();
window.addEventListener("resize", function () {
clearTimeout(t);
t = setTimeout(w, 300)
}, false);
})();
关于移动端适配方案--rem
于 2019-11-07 13:10:18 首次发布