//the "REM" phone screen is compatible with Android users who have changed the default font sizefunctionadapt (Designwidth, rem2px) {//designwidth: ' Design width ' 1rem==rem2px+ ' px ' varD = window.document.createElement (' div '); D.style.width= ' 1rem '; D.style.display= "None"; varHead = Window.document.getElementsByTagName (' head ') [0]; Head.appendchild (d); varDefaultfontsize = parsefloat (window.getComputedStyle (D,NULL). GetPropertyValue (' width ')); D.remove (); Document.documentElement.style.fontSize= window.innerwidth/designwidth * rem2px/defaultfontsize * 100 + '% '; varst = document.createelement (' style ');//adapt to horizontal screen, vertical screen varPortrait = "@media screen and (min-width:" + window.innerwidth + "px) {html{font-size:" + ((Window.innerwidth/(DESIGNWI DTH/REM2PX)/defaultfontsize) * 100) + "%;}}"; varLandscape = "@media screen and (min-width:" + window.innerheight + "px) {html{font-size:" + ((Window.innerheight/(Desig NWIDTH/REM2PX)/defaultfontsize) * 100) + "%;}}"st.innerhtml= Portrait +landscape; Head.appendchild (ST); returndefaultfontsize};varDefaultfontsize = ADAPT (640, 100);
Mobile REM Font Adaptation JS