The mobile side uses REM to make the font adaptive

Source: Internet
Author: User

REM is a new unit introduced by CSS3, relative to PX and em, I feel rem is more convenient, especially for mobile font adaptive layouts .

REM is set based on the font size of the HTML.

The basic font size of HTML is 16px, so you can add the following code:

1{font-size: 62.5%;  /*10÷16x100% = 62.5%*/}

This setting means that the HTML font-size is set to 10px for easy calculation.

Then it is possible to use REM as a unit, and it is absolutely feasible to replace PX with REM, such as:

1  #div1{font-size: 1.4rem;}

Because REM is set according to the HTML font size (10px), 1.4rem is 14px.

Note, however, that setting the fixed size directly on the mobile side does not apply ... You can try it if you don't believe it.

However, a percentage can be used, such as:

1 #div1 {font-size: 140%rem;}

Nuu, so you can adapt yourself.

The mobile side uses REM to make the font adaptive

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.