Mobile REM Layout, user-adjusted phone font size or browser font size causes problems with page layout errors

Source: Internet
Author: User

First, the user changes the size of the phone font settings, affecting the Web page opened in the app.

The size of the phone font is set to affect the app's page.
Android can be configured via WebView webview.getsettings (). Settextzoom (100) You can disable zooming and display in hundred percent.

Second, the user adjusts the browser font size, affects the Web page opened from the browser

The browser sets the font size, which affects the page that the browser opens. JS can control the user to modify the font size, so that the page is not affected.

(function(Doc, win) {//use native method to get the font size of user-set browser (IE compatible)        if(doc.documentElement.currentStyle) {varuser_webset_font=doc.documentelement.currentstyle[' FontSize ']; }        Else {            varUser_webset_font=getcomputedstyle (Doc.documentelement,false) [' FontSize ']; }//scale factor after rounding vs. default 16px        varXs=parsefloat (User_webset_font)/16;//set the font size for the REM JS setting        varView_jsset_font,result_font; varDocel =doc.documentelement, Resizeevt= ' Orientationchange 'inchWindow? ' Orientationchange ': ' Resize ', clientwidth, Recalc=function() {clientwidth=Docel.clientwidth; if(!clientwidth)return; if(!doc.addeventlistener)return; if(clientwidth<750){//set the font size for the REM JS settingVIEW_JSSET_FONT=100 * (clientwidth/750);//The final font size is REM font/factorResult_font=view_jsset_font/xs;//set the root font sizeDocEl.style.fontSize = Result_font + ' px '; }            Else{docEl.style.fontSize= + ' px ';    }        }; Win.addeventlistener (Resizeevt, Recalc,false); Doc.addeventlistener (' domcontentloaded ', Recalc,false);}) (document, window);

Mobile REM Layout, user-adjusted phone font size or browser font size causes problems with page layout errors

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.