Conversion rate of pt, em, px, percent, other

前端 未结 4 2136
余生分开走
余生分开走 2020-12-15 09:26

More so than less I run into times when I need to use pt instead of px or em instead of pt, or whatever the case, and trying to find the right size for something bigger than

4条回答
  •  星月不相逢
    2020-12-15 09:49

    Ems and %s are relative values which can change depending on your context. Normally, 1em is equivalent to 16px, but if you change your body's font-size 1em is equivalent to whatever you changed it to. 1.25em is also equivalent to 125%.

    Generally, 72pt is equivalent to 1 inch, but it shouldn't be used outside of print CSS.

    px is also absolute but is highly dependent on the client device DPI. This varies greatly, but most devices handle px values in a perdictable manner -- 10px on a retina iphone displays the same as 10px on a pre-retina device.

    There's also rem which refers to the font-size of your html element. See more: http://snook.ca/archives/html_and_css/font-size-with-rem

提交回复
热议问题