font-size:large对1em的字体有什么影响?

时间:2010-10-14 11:29:37

标签: css font-size em

我正在使用CSS属性font-size:larger更新包含许多部分的网站。

我想替换它,以便它使用EM代替,因为它更明确的是大小。

如果将font-size:larger应用于1em字体,则新字体的EM数量是多少?像1.2em这样的东西?

3 个答案:

答案 0 :(得分:4)

W3C CSS2 Fonts文件中所述:

<relative-size>
A <relative-size> keyword is interpreted relative to the table of font sizes
and the font size of the parent element. Possible values are: [ larger | smaller ].
For example, if the parent element has a font size of 'medium', a value of 'larger'
will make the font size of the current element be 'large'. If the parent element's
size is not close to a table entry, the UA is free to interpolate between table
entries or round off to the closest one. The UA may have to extrapolate table values
if the numerical value goes beyond the keywords.

在此之下,说:

Note 2. In CSS1, the suggested scaling factor between adjacent indexes was 1.5, which
user experience proved to be too large. In CSS2, the suggested scaling factor for a
computer screen between adjacent indexes was 1.2, which still created issues for the
small sizes. Implementation experience has demonstrated that a fixed ratio between
adjacent absolute-size keywords is problematic, and this specification does not
recommend such a fixed ratio.

我希望这能回答你的问题。

答案 1 :(得分:1)

根据SitePoint Reference,你的猜测是完全正确的。大多数浏览器会将字体大小增加1.2em倍,但没有标准可以这样做。

W3C建议您使用em或%进行大小调整,因为页面上元素的大小将相互关联,而不是依赖于某些可能不会在某些内容中使用的任意约定。 - 通用浏览器。

答案 2 :(得分:0)

font-size:larger将导致所选元素的font-size大于其父容器的font-size。 CSS的标准字体大小是中等的。实际的pxem值取决于客户端/浏览器。通常它是1em,普通转换是1em = 16px。