CSS3 relative units: em && rem

Source: Internet
Author: User

Em:

1. font-sizeof em relative to the parent element of the Element. For example, if a <div> 's font-size is "16px", then if its child element's font size is set to "0.75em", then its font size is calculated to be equivalent to "0.75 * 16px = 12px"

2.p { margin: 1em 0 }

Indicates the paragraph left 1em blank, then the specific P element font size if it is 12px, White is also 12px, if the font is 16px, white is also 16px.

Rem:

REM is relative to the HTML root element, which is the HTML element, such as:

html{
font-size: 14px;
}
p{
font-size: 2rem; /* 此时p的字体大小为28px,即html的
font-size和p的*/
}

CSS3 relative units: em && rem

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.