/* # to set the HTML font according to the wide-height ratio, width=device-width initial-scale=1 # @pargam Win window Windows object # @pargam option{DESIGNWI DTH: Design manuscript width, must designheight: Design draft height, do not preach the proportion according to the width to calculate, optional designfontsize: Design draft for the calculation of font size, default 20, Optional callback: Font calculation After the callback function, optional} # return Boolean; # PS: Please try to run this JS computing font */!function (win, option) {var count = 0, Designwidth = option.designwidth, Designheigh t = Option.designheight | | 0, designfontsize = option.designfontsize | | callback = Option.callback | | NULL, root = document.documentelement, BODY = document.body, rootwidth, newSize, t, self; Returns the root element font calculation result function _getnewfontsize () {var scale = Designheight!== 0? Math.min (Win.innerwidth/designwidth, win.innerheight/designheight): win.innerwidth/designwidth; return parseint (Scale * 10000 * designfontsize)/10000; }!function () {rootwidth = Root.getboundingclientrect (). width; Self = self? Self:arguments.callee; If this screenIf the width is not accurate, try to get the resolution again, try only 20 times, otherwise use win.innerwidth to calculate if (rootwidth!== win.innerwidth && count <) {win.se Ttimeout (function () {count++; Self (); }, 0); } else {newSize = _getnewfontsize (); If the CSS is already compatible with the current resolution regardless of if (newSize + ' px '!== getcomputedstyle (root) [' font-size ']) {root.style.fontSize = NewS ize + "px"; Return callback && callback (newSize); }; }; }(); Change the fontsize when the screen is switched, choose to use Win.addeventlistener ("Onorientationchange" in window as needed). "Orientationchange": "Resize", function () {cleartimeout (t); t = setTimeout (function () {self (); }, 200); }, False);} (window, {designwidth:750,//designheight:960, designfontsize:100, callback:function (argument) {//console . log (argument)}});
Mobile-side layout rem