The conversion of REM in CSS

Source: Internet
Author: User

REM seems to also be a relative size value, which is relative to the root element html{font-size: 87.5%;} (that is, 14px, which is the setting in the Twentytwelve default theme). Then the other font is the value that you want to divide by 14 , such as the default Twentytwelve theme size is 960px, and the conversion to REM is 960/14=68.57142857142857rem (which I use computer calculators to calculate, More accurate than the default, hehe), padding 24px is 24/14=1.714285714285714rem (certainly more accurate than the CSS file), and so on.

The above 14 is a variable, relative to your root element HTML font size settings, if you set the 62.5%, then the divisor becomes 10, the table

The above 14 is a variable, relative to your root element HTML font size settings, if you set the 62.5%, then the divisor becomes 10, the comparison chart as the right:

The advantage of this REM unit is what I don't know, but if you choose 62.5% of the font size of the root element, then the conversion between PX and REM is px directly divided by 10 to get REM, which is much simpler than EM, and now I have no idea how the conversion between EM and px.

In addition, the REM in IE8 and IE8 the following version does not support other browsers are supported, if you want to consider IE8 and a bit, you can like the twentytwelve default file set px and then set a REM can be.

The conversion of REM in CSS

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.