How to use REM units

Source: Internet
Author: User

Recently made mobile end, is really rem, EM and px conversion to kill, read a lot of documents, it seems to understand, this is not today with the mask circle.

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

Look at the next bootstrap style sheet, HTML {font-size:62.5%} body {font-size:14px;}, the other style slightly, it's about the two main.

Unfortunately, the eldest sister has so big eyes, from yesterday to today has been the EM as REM, resulting in the more depressed ... Not to mention, the explanation is as follows:

In fact, you can learn this setting of bootstrap, because the use of EM and REM when not affect each other, because REM is to refer to your HTML font-size, you do not set the body, it does not matter to me.

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

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

2, HTML {font-size: percent;} Hundred score = cardinal/16

Cardinal 1000 Score 62.5%

Cardinal 1400 Score 87.5%

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

In other words, when you set HTML {font-size:62.5%;}, you want to set the font size of the container 14px, converted to REM is 14px/10--1.4rem such

(If you want to test, take the Firefox firebug test, because the chrome below 12px Invalid font size, if you want to set less than 12px font size, chrome also has a solution, their own Baidu is good)

If the use of EM units, the computer will find your own body settings, will not control your HTML is how to set it?

For example, our great bootstrap to the body {font-size:14px} After this setting, if I want a 14px outer distance, I use 14px/14px--1em this way.

The above is my summary, if there is a mistake, you are welcome to correct OH ~ ~


Source: http://www.cnblogs.com/YYvam1288/p/5123272.html

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.