Mobile-Side Settings-----REM

Source: Internet
Author: User

For the different size of the mobile screen, if the setting px is really a bit of impact on the user experience, on the small screen is too large, large screen too small to implement the response, so the introduction of the concept of REM.

REM is relative to the root element

In my project is the use of such a section of JS code.

(function () {varresizeevt = ' Orientationchange 'inchWindow? ' Orientationchange ': ' Resize ';varRecalc =function () {varClientWidth =Document.body.clientWidth;if(!clientwidth) {return;} Document.documentElement.style.fontSize= ten * (clientwidth/320) + ' px ';document.documentElement.style.visibility= ' Visible ';}if(!Document.documentElement.addEventListener) {return;} Window.addeventlistener (Resizeevt,recalc,false); Window.addeventlistener (' domcontentloaded ', Recalc,false);}) ();

When designed to give me psd, the measurement text for 40px,html uses REM value =40/20=2rem.

REM is not only used in units of text, but also in units of height,width,padding,marigin,line-height and so on.

Mobile-Side Settings-----REM

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.