[CSS3 tutorial] explanation of relative unit rem, css3rem

Source: Internet
Author: User

[CSS3 tutorial] explanation of relative unit rem, css3rem

Author: zhanhailiang Date:
Definition

CSS3 adds a relative unit rem. Its official definition is as follows:

Font size of the root element

Difference in rem, em, px units

Both rem and em units are relative sizes, and px is absolute. The difference is that

  1. Em is based on the current element (if it is not set, it inherits its parent element) font-size, which may cause some combination problems;
  2. Rem is only relative to the font-size of the root element, that is, you only need to set the font-size of the root element, and other elements can use the rem unit to set the corresponding percentage;
Compatibility

At present, all browsers except IE8 and earlier versions support rem. For browsers that do not support it, the solution is very simple, that is, to write an absolute unit statement. These browsers ignore the font size set with rem.

Example
<Html> Read more

 
  1. (W3C) EM, PX, PT, CM, IN...
  2. Understand the unit of length in css
  3. CSS3 Tutorial: Explanation of relative unit rem
  4. IE8 HACK Introduction

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.