Use of REM, EM units on the mobile side

Source: Internet
Author: User

  

Many documents are always said to use REM to set the HTML font-size, with EM to set the body font-size

Looked at the next bootstrap style sheet, HTML {font-size:62.5%;} body {font-size:14px;}, speak of these two main.

The explanations are as follows:

Because the use of EM and REM is not affected, because REM is to refer to your HTML font-size, tube your body set not set, it's all right with me.

First, then if you are certain that you want to use REM units, follow these three steps to calculate:

1, determine the base: General 10px, you remember the line, do not write into the code

2, HTML {font-size: percent;} Percent score = radix/16

Base 1000 score 62.5%

Base 1400 score 87.5%

3. px conversion REM formula = desired PX Value/cardinality

That is, when you set the HTML {font-size:62.5%;}, you want to set the font size 14px for the text in the container, and convert it to REM is 14px/10--1.4rem

(If you want to test, take the Firefox firebug test, because the size of chrome below 12px failure ha, if you want to set the size of less than 12px, Chrome also has a solution, Baidu is good)

Second, if the use of EM units, the computer will go to find your body settings, do not care how HTML is set?

For example, our great bootstrap to body {font-size:14px;} so set, if I want a 14px margin, I will use 14px/14px--1em so.

The above is my own summary, if there are errors, welcome you to correct me Oh ~ ~

Use of REM, EM units on the mobile side

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.