The size of the CSS unit Px,em,rem difference

Source: Internet
Author: User
Px

px Pixels (Pixel). Relative length units. Pixel px is relative to the display screen resolution. The use of PX can accurately locate page elements, however, the display of different display pages may vary, more difficult to compatible.

Em

EM is the size of the font that is scaled based on the datum. The EM essence is a relative value, not a specific number. EM is calculated relative to the attributes of the parent element, if the parent element's font-size is 16px,2em=2*16px=32px.

Rem

REM is also a relative value, but REM is calculated relative to the font-size of the HTML root element.

The default font size of the general browser is 16px, the conversion between units convenient, 10÷16=0.625, you can set the HTML font-size for 62.5%,1em=10px,16px=1.6em. Because Chrome has a minimum font size of 12px, this setting eventually gets bigger.

The size of the CSS unit Px,em,rem difference

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.