px, EM, REM,% units

Source: Internet
Author: User

Px:

Pixel (pixel) relative length units, pixels are relative to the display screen resolution

Em:

Relative length unit, relative to the font size of the text within the current object. If the current font size for inline text is not considered set, the default font size relative to the browser

1, the value of EM is not fixed

2, EM inherits the font size of the parent element

P{font-size:2em;}
A{font-size:2em;} < P >< a > We're All good kids. </a></p>

Equivalent to:
A{font-size:4em;} < P >< a > We're All good kids. </a></p>

Div{font-size:2em;} P{font-size:2em;} A{font-size:2em;} < Div >    < P >        < a > We're All good kids. </a>    </p>  </div>     equal to: a{font-size:8em;} (2*2*2=8)

Rem:

CSS3 a new relative unit (root em, root em)

When REM sets the font size for an element, it is still relative in size, but relative to the HTML root element

Advantage: It can adjust all font sizes proportionally, and avoid the chain reaction of font size lamination

Currently, in addition to IE8 and earlier versions, all browsers support REM, and if not supported, write an absolute unit declaration, then these browsers will ignore the REM-set font size

p{    font-size:14px;    Font-size:0.875rem;}

Pt:

Commonly used in the printing industry, the meaning of the pound, generally for page printing and typesetting

Conversion:

PX to em:12px/16px=0.75em;

PX to%:12px/16px*100=75%;

px to pt:16px* (72pt/96px) =12pt;

EM to px:0.75em*16px=12px;

Conversion tools

http://pxtoem.com/

px, EM, REM,% units

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.