移动端的字号大小rem自适应js

烟雨朦胧、人去楼空 0     62      前端   0     0
移动端的字号大小rem自适应js,移动端的字号大小rem自适应js

移动端的字号大小rem自适应js

// !function(e,t){function n(){t.body?t.body.style.fontSize=12*o+"px":t.addEventListener("DOMContentLoaded",n)}function d(){var e=i.clientWidth/10;i.style.fontSize=e+"px"}var i=t.documentElement,o=e.devicePixelRatio||1;if(n(),d(),e.addEventListener("resize",d),e.addEventListener("pageshow",function(e){e.persisted&&d()}),o>=2){var a=t.createElement("body"),s=t.createElement("div");s.style.border=".5px solid transparent",a.appendChild(s),i.appendChild(a),1===s.offsetHeight&&i.classList.add("hairlines"),i.removeChild(a)}}(window,document); ! function(a, b) { function c() { var c, b = f.getBoundingClientRect().width; b / i > 600 && (b = 600 * i), c = b / 10, f.style.fontSize = c + "px", k.rem = a.rem = c, setTimeout(function() { k.setPFullMinHeight() }) } var d, l, m, n, o, p, q, r, e = a.document, f = e.documentElement, g = e.querySelector('meta[name="viewport"]'), h = e.querySelector('meta[name="flexible"]'), i = 0, j = 0, k = b.flexible || (b.flexible = {}); g ? (l = g.getAttribute("content").match(/initial\-scale=([\d\.]+)/), l && (j = parseFloat(l[1]), i = parseInt(1 / j))) : h && (m = h.getAttribute("content"), m && (n = m.match(/initial\-dpr=([\d\.]+)/), o = m.match( /maximum\-dpr=([\d\.]+)/), n && (i = parseFloat(n[1]), j = parseFloat((1 / i).toFixed(2))), o && (i = parseFloat(o[ 1]), j = parseFloat((1 / i).toFixed(2))))), i || j || (a.navigator.appVersion.match(/android/gi), p = a.navigator.appVersion .match(/iphone/gi), q = a.devicePixelRatio, j = 1 / (i = p ? q >= 3 && (!i || i >= 3) ? 3 : q >= 2 && (!i || i >= 2) ? 2 : 1 : 1)), f.setAttribute("data-dpr", i), g || ((g = e.createElement("meta")).setAttribute("name", "viewport"), g .setAttribute("content", "initial-scale=" + j + ", maximum-scale=" + j + ", minimum-scale=" + j + ", user-scalable=no, viewport-fit=cover"), f.firstElementChild ? f.firstElementChild.appendChild(g) : (r = e.createElement( "div"), r.appendChild(g), e.write(r.innerHTML))), a.addEventListener("resize", function() { clearTimeout(d), d = setTimeout(c, 300) }, !1), a.addEventListener("pageshow", function(a) { a.persisted && (clearTimeout(d), d = setTimeout(c, 300)) }, !1), "complete" === e.readyState ? e.body.style.fontSize = 12 * i + "px" : e.addEventListener("DOMContentLoaded", function() { e.body.style.fontSize = 12 * i + "px" }, !1), c(), k.dpr = a.dpr = i, k.refreshRem = c, k.rem2px = function(a) { var b = parseFloat(a) * this.rem; return "string" == typeof a && a.match(/rem$/) && (b += "px"), b }, k.px2rem = function(a) { var b = parseFloat(a) / this.rem; return "string" == typeof a && a.match(/px$/) && (b += "rem"), b }, k.setPFullMinHeight = function() { var a = innerHeight; k.stylesheet || (k.stylesheet = document.createElement("style"), document.head.appendChild(k.stylesheet)), k.stylesheet .textContent = ".p_full{min-height:" + a + "px}" } }(window, window.lib || (window.lib = {})); 


captcha
忘记密码? 注册
第三方登录
微信赞赏
支付宝赞赏