REM layout, when user adjusts phone font size/user adjusts browser font size, layout disorder problem

Source: Internet
Author: User

First, the user adjusts the browser font size, affects the Web page that opens 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) {//) the font size (ie doc.documentElement.currentStyle) {var user_webset_font=) of the browser that gets the user's settings in the native method doc.documentelement.currentstyle[' FontSize ']; } else {var user_webset_font=getcomputedstyle (doc.documentelement,false) [' FontSize '];}//After rounding with the default 16px scale factor var xs= Parsefloat (User_webset_font)/16;//sets the font size of the REM JS settings var view_jsset_font,result_font;var docel = doc.documentelement, resizeevt = ' orientationchange ' in window? ' Orientationchange ': ' resize ', Clientwidth,recalc = function () {clientwidth = Docel.clientwidth;if (!clientwidth) Return;if (!doc.addeventlistener) return;if (clientwidth<750) {//Set the font size of REM JS settings view_jsset_font=100 * ( CLIENTWIDTH/750);//The final font size is REM font/factor result_font=view_jsset_font/xs;//set root font Size docEl.style.fontSize = Result_font + ' PX ';} Else{docel.style.fontsize = + ' px ';}}; Win.addeventlistener (Resizeevt, Recalc, False);d Oc.addeventlistener (' domcontentloaded ', Recalc, False);}) (document, window);

  

Second, 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.

REM layout, when user adjusts phone font size/user adjusts browser font size, layout disorder problem

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.