The mobile page uses REM to do the matching

Source: Internet
Author: User

The mobile page uses REM to do the matching

REM Introduction

REM (font size of the root element) refers to the unit of font size relative to the root element (that is, the HTML element).
Assuming that the font size of the root element is 10px , then 5rem the size is 5*10=50px , for example

1 html{2font-size:10px; 3 }4width:2rem;/* 2*10 = 20px;*/5Margin:1rem; 6 }7img{8width:.6rem; 9 }

REM to make a fit

We used to do this. Page: Viewport width set to Device-width, then select the minimum width we need for compatible devices (typically 320px). Make the page based on the minimum width. Unit usage px and percentage. On the different width of the device, the font size of the page, the content size is the same, the difference is that the large screen of the space between the larger than the small screen. So the disadvantage of this is that the page does not work well on some devices.

If you use REM to page, we will set different font sizes on the root element depending on the device width. The wider the width, the larger the font size. Then px replace it with the original used rem place. In this way, the font size, content size, is larger as the width of the screen becomes larger.

Specific practices

1 sets a different font size on the root element depending on the device width.
In order to easily convert the PX in the design to REM in the page, I set 1rem to 100px in a design with a width of 640px.

2 when making a page
Zooms the width of the design artwork to 640px. In the previous step, 1rem was the value of 100px in this design. The width of the screen is also(640 / 100) = 6.4rem)

Always encourage yourself to:

Immersed in reading, head up a man!

Do not climb mountains do not know the sky high also, not the Deep brook not know the thick Also

Cowardly people will only be deterred, reckless people can only be cited as the burning body, only the truly courageous people can be invincible

In our world, we never give medals to a sad, outdated person.

The character of the waves is the countless times the reef is shattered and countless flash to the reef,

The soles were worn, not equal to the road to the head.

Loose the strings, never play the strong voice of the times.

The person lying in the quilt does not feel the warmth of the sun.

Not complacent, not willing to mediocrity, it may be in the courage to forge ahead in the struggle to play the magnificent life of the music room.

Not to cultivate, not to sow, and then fat fertile soil also long not to grow crops, not to struggle, not to create, and then the United States of youth can not bear fruit.

  (Small little Tail/original)

The mobile page uses REM to do the matching

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.