This code is added to the head tag, can be added to different models of mobile devices, set the size of the HTML fontsize, which can be used as REM to solve the mobile-adaptive scheme
!function (n,m) {function L () {var a=i.getboundingclientrect () .width;a/f>750&& (a=750*f); var d=a/10;i. style.fontsize=d+ "px", D.rem=n.rem=d}var k,j=n.document,i=j.documentelement,h=j.queryselector (' meta[name= ' Viewport "]), G=j.queryselector (' meta[name=" flexible "]"), f=0,e=0,d=m.flexible| | (m.flexible={}), if (H) {Console.warn ("the scaling is set according to the existing META tag"), Var c=h.getattribute ("Content"). Match (/initial\-scale = ([\d\.] +)/); c&& (E=parsefloat (c[1]), F=parseint (1/e))}else{if (G) {var b=g.getattribute ("content"), if (B) {var a=b.match (/ Initial\-dpr= ([\d\.] +)/), Z=b.match (/maximum\-dpr= ([\d\.] +)/); a&& (F=parsefloat (a[1)), E=parsefloat ((f. f). ToFixed (2)),z&& (F=parsefloat (z[1)), E=parsefloat ((1/ F). toFixed (2))}}}if (! f&&! E) {var y=n.navigator.useragent,x= (!! Y.match (/ANDROID/GI),!! Y.match (/iphone/gi)), w=x&&!! Y.match (/os 9_3/), V=n.devicepixelratio; f=x&&!w?v>=3&& (! f| | f>=3)?3:v>=2&& (! f| | f>=2)? 2:1:1,e=1/f}if (I.setattribute ("DATA-DPR", F),! H) {if (h=J.createelement ("meta"), H.setattribute ("name", "viewport"), H.setattribute ("content", "initial-scale=" +e+ ", Maximum-scale= "+e+", minimum-scale= "+e+", User-scalable=no "), I.firstelementchild) { I.firstelementchild.appendchild (h)}else{var u=j.createelement ("div"); U.appendchild (h), J.write (U.innerHTML)}} N.addeventlistener ("Resize", function () {cleartimeout (K), K=settimeout (l,300)},!1), N.addeventlistener ("Pageshow", function (b) {b.persisted&& (Cleartimeout (K), K=settimeout (l,300))},!1), "complete" ===j.readystate? j.body.style.fontsize=12*f+ "px": J.addeventlistener ("domcontentloaded", function () {j.body.style.fontsize=12*f+ " PX "},!1), L (), d.dpr=n.dpr=f,d.refreshrem=l,d.rem2px=function (d) {var c=parsefloat (d) *this.rem;return" string "= = typeof D&&d.match (/rem$/) && (c+= "px"), c},d.px2rem=function (d) {var c=parsefloat (d)/this.rem;return "String" ==typeof D&&d.match (/px$/) && (c+= "REM"), C}} (window,window.lib| | (window.lib={}));
Mobile-adaptive