What is the value of the css 'ex' unit?

后端 未结 5 881
时光说笑
时光说笑 2020-11-28 03:21

(Not to be confused with Xunit, a popular .Net unit testing library.)

Today in a fit of boredom I started inspecting Gmails DOM (yes, I was very bored).

Ever

5条回答
  •  执笔经年
    2020-11-28 03:39

    Note that, terms like "single/double line spacing" actually mean the offset between two adjacent lines, measured by em. So "double line spacing" means each line has a height of 2 em.

    Therefore, if you want to specify a vertical distance that is proportional to "lines", use em. Only use ex if you want the actual height of lowercase letter, which is, I dare say, a much rarer instance.

    UPDATE: The web standard allows the browser to use either 0.5em as ex or derive from the font.

    However, there is no way to reliably embed any "x-height" information in a font (OpenType or webfont).

    Hence, the former possibility makes the ex-unit redundant, and the latter lacks any reliable means to happen. And the fact that either is possible makes it even less reliable.

    Thus I argue for the lack of value of the ex-unit.

提交回复
热议问题