CSS 度量单位“em”实际上代表什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15827038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does CSS measurement unit 'em' actually stand for?
提问by drkthng
As the title says, I want to know what exactly the CSS unit 'em' stands for.
As in 'cm' stands for centimeter.
正如标题所说,我想知道 CSS 单位“em”究竟代表什么。
如“厘米”代表ÇENTI米安静。
I am not asking what 'em' is or how it is used!
我不是在问“它们”是什么或如何使用它!
I couldn't find an answer on W3C.
The Wikipediaarticle was already saying "something":
The name of em is related to M. Originally the unit was derived from the width of the capital "M" in the given typeface.
em 的名称与 M 相关。最初该单位源自给定字体中大写字母“M”的宽度。
My interpretation of the first sentence would be that 'em' is the pronunciation/phonetic for the letter 'M'.
But reading the second sentence, it seems that the 'e' in 'em' stands for something regarding the width of the letter 'M'.
So I'm still lost, what 'em' really stands for!
我对第一句话的解释是“em”是字母“M”的发音/语音。
但是阅读第二句话,似乎“em”中的“e”代表与字母“M”的宽度有关的某些内容。
所以我还是迷路了,“他们”到底代表什么!
回答by BoltClock
That is a historical definition; in modern usage it simply refers to the size of the font, with the word "em" itself no longer having any practical or relevant meaning. As a matter of fact, the same Wikipedia article expands on this evolution in its usage and meaning in a later section:
这是一个历史定义;在现代用法中,它仅指字体的大小,“em”一词本身不再具有任何实际或相关含义。事实上,同一篇维基百科文章在后面的部分中扩展了这种演变的用法和含义:
One em was traditionally defined as the width of the capital "M" in the current typeface and point size, as the "M" was commonly cast the full-width of the square "blocks", or "em-quads" (also "mutton-quads"), which are used in printing presses. However, in modern typefaces, the character M is usually somewhat less than one em wide. Moreover, as the term has expanded to include a wider variety of languages and character sets, its meaning has evolved; this has allowed it to include those fonts, typefaces, and character sets which do not include a capital "M", such as Chinese and the Arabic alphabet. Thus, em generally means the point size of the font in question, which is the same as the height of the metal body a font was cast on.
一个 em 传统上被定义为当前字体和点大小中大写字母“M”的宽度,因为“M”通常是方形“块”或“em-quads”(也称为“ mutton-quads”),用于印刷机。然而,在现代字体中,字符 M 通常略小于 1 em 宽。此外,随着该术语扩展到包括更广泛的语言和字符集,其含义也发生了变化;这使它能够包含那些不包含大写“M”的字体、字体和字符集,例如中文和阿拉伯字母。因此,em 通常表示所讨论字体的磅值,它与铸造字体的金属体的高度相同。
Particularly in terms of CSS, an "em" doesn't necessarily refer to the width of the capital M for a particular font; it's just a relative quantity.
特别是在 CSS 方面,“em”不一定指特定字体的大写字母 M 的宽度;这只是一个相对数量。
If you're asking about the etymologyof the word "em", Wikipedia itself only contains a reference to the Adobe Glossary, which has little more to say about it:
如果您要问“em”这个词的词源,维基百科本身只包含对Adobe Glossary的引用,它几乎没有什么可说的:
A common unit of measurement in typography. Em is traditionally defined as the width of the uppercase M in the current face and point size. It is more properly defined as simply the current point size. For example, in 12-point type, em is a distance of 12 points.
排版中常用的度量单位。Em 传统上定义为当前面和点大小中大写字母 M 的宽度。更恰当地将其定义为当前点的大小。例如,在 12 点类型中,em 是 12 点的距离。
It's not explicitly mentioned anywhere authoritative that it's a phonetic representation of the capital M, but considering its namesake definition I wouldn't rule out such a possibility.
它没有在权威的任何地方明确提到它是大写 M 的语音表示,但考虑到它的同名定义,我不排除这种可能性。
回答by user2029015
In my opinion em stands for nothing but just pronunciation/phonetic for the letter 'M'. Similarly we have ex, one ex is the x-height of a font (x-height is usually about half the font-size).
在我看来,em 仅代表字母“M”的发音/语音。类似地,我们有 ex,一个 ex 是字体的 x 高度(x 高度通常约为字体大小的一半)。