! function (e) {
function t() {
var t = n.clientWidth,
r = "}";
!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) &&
t > 1024 &&
(t = 750, r = ";max-width:" + t + "px;margin-right:auto!important;margin-left:auto!important;}"),
e.rem = t / 10,
/ZTE U930_TD/.test(navigator.userAgent) && (e.rem = 1.13 * e.rem),
/Android\s+4\.4\.4;\s+M351\s/.test(navigator.userAgent) && (e.rem = e.rem / 1.05),
/Android\s+5\.0\.1;\s+MX4\s/.test(navigator.userAgent) && (e.rem = 1.06382 * e.rem),
i.innerHTML = "html{font-size:" + e.rem + "px!important;}body{font-size:" + 12 * (t / 320) + "px" + r
}
var n = document.documentElement,
i = document.createElement("style");
n.firstElementChild.appendChild(i), e.addEventListener("resize", function () {
t()
}, !1), e.addEventListener("pageshow", function (e) {
e.persisted && t()
}, !1), t()
}(window);
移动端js动态计算rem的方法
最新推荐文章于 2023-03-04 15:30:21 发布