JS Dynamic adaptation Mobile end font-size, Unit: REM

Source: Internet
Author: User

For example: At present I have a PSD chart, size of 640*1010, suitable for Apple 5 mobile phone .

Method steps:

1. I use font-size=10px as the initial pixel size of the 640*1010 phone; 1rem=10px;

at this time there is a text on the PSD size of 20px, that is, the current size of my font is expressed in rem:Font-size:1rem (the size of the PSD is twice times the size of the HTML, so first divided by 2 to get the correct PX, After conversion rem divided by 2 again OK)

REM units for a variety of phones:

2. Get the width: var windowwidth=$ (this) that I currently use on my phone . innerwidth ();

3. Proportional conversion get PX: windowwidth/m= 320/10 ========= (get M value) currently using the phone

4. Assign the upper x value to the HTML tag that is currently using the phone page:

JS Dynamic adaptation Mobile end font-size, Unit: 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.