How is an em calculated?

后端 未结 3 1038
独厮守ぢ
独厮守ぢ 2021-01-01 21:35

I have noticed that you can use 1em and it will look different on different sites.

What is an em in proportion to?

  • The font used?
  • The bigges
3条回答
  •  太阳男子
    2021-01-01 22:01

    According to the W3C an em:

    "is equal to the computed value of the 'font-size' property of the element on which it is used. The exception is when 'em' occurs in the value of the 'font-size' property itself, in which case it refers to the font size of the parent element."

    In other words, ems don't have an absolute size. They take on their size values based on where they are. For most Web designers, this means that they are in a Web browser, so a font that is 1em tall is exactly the same size as the default font size for that browser.

    For most browsers, default value 1em = 16px

提交回复
热议问题