Can directly refer to this JS file
!function (Win) {
function Resize () {
var domwidth = Domele.getboundingclientrect (). width;
if (domwidth/v > 540) {
Domwidth = 540 * v;
}
Win.rem = DOMWIDTH/16;
DomEle.style.fontSize = Win.rem + "px";
}
var V, Initial_scale, timecode, dom = win.document, Domele = dom.documentelement, viewport = Dom.queryselector (' meta[name= "Viewport"], flexible = Dom.queryselector (' meta[name= "flexible"] ");
if (viewport) {
Viewport:<meta name= "viewport" content= "initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5,user-scalable =no,minimal-ui "/>
var o = viewport.getattribute ("content"). Match (/initial\-scale= (["']?) ([\d\.] +) \1?/);
if (o) {
Initial_scale = parsefloat (o[2]);
v = parseint (1/initial_scale);
}
} else {
if (flexible) {
var o = flexible.getattribute ("content"). Match (/initial\-dpr= (["']?) ([\d\.] +) \1?/);
if (o) {
v = parsefloat (o[2]);
Initial_scale = parsefloat ((1/v). toFixed (2))
}
}
}
if (!v &&!initial_scale) {
var n = (Win.navigator.appVersion.match (/android/gi), Win.navigator.appVersion.match (/iphone/gi));
v = win.devicepixelratio;
v = n? V >= 3? 3:v >= 2? 2:1: 1, Initial_scale = 1/v
}
Without the viewport label
if (Domele.setattribute ("DATA-DPR", V),!viewport) {
if (viewport = dom.createelement ("meta"), Viewport.setattribute ("name", "viewport"), Viewport.setattribute ("content" , "initial-scale=" + Initial_scale + ", maximum-scale=" + Initial_scale + ", minimum-scale=" + Initial_scale + ", User-sca Lable=no "), Domele.firstelementchild) {
DomEle.firstElementChild.appendChild (viewport)
} else {
var m = dom.createelement ("div");
M.appendchild (viewport), Dom.write (m.innerhtml)
}
}
WIN.DPR = v;
Win.addeventlistener ("Resize", function () {
Cleartimeout (timecode), timecode = SetTimeout (resize, 300)
}, False);
Win.addeventlistener ("Pageshow", function (b) {
B.persisted && (Cleartimeout (timecode), timecode = SetTimeout (resize, 300))
}, False);
/* If you don't feel the need to finish, set the body font to 12
"complete" = = = Dom.readystate? Dom.body.style.fontSize = * v + "px": Dom.addeventlistener ("domcontentloaded", function () {
Dom.body.style.fontSize = * v + "px"
}, False);
*/
Resize ();
} (window);
REM (JS code that automatically adjusts REM values based on the size of the phone screen)