2

W3C 标准文档说:

当指定的媒体特征之一未知时,用户代理将媒体查询表示为“不是全部”。

然后它给出了以下示例:

<link rel="stylesheet" media="screen and (max-weight: 3kg) and (color), (color)" href="example.css" />

然后它说第一个媒体查询将被表示为“不是全部”并评估为假,第二个媒体查询的评估就像第一个媒体查询没有被指定一样有效。

为什么会这样。我希望这是因为 max-weight 的 3kg 值不是有效值,文档中没有对此进行解释。但是,除了“未知媒体特征值”之外,我看不到任何未知的媒体特征,这在文档中的“未知媒体特征”之后单独讨论。我认为这个例子应该放在“未知媒体特征值”之下,而不是放在“未知媒体特征”之下。

4

1 回答 1

2

The unknown media feature that the example is referring to is max-weight. Once that is encountered, the 3kg value is no longer relevant since it will never be applicable anyway, because the browser won't know what to do with max-weight in the first place. So it skips that media query altogether, leaving you effectively with this:

<link rel="stylesheet" media="not all, (color)" href="example.css" />

Which is the same as this:

<link rel="stylesheet" media="(color)" href="example.css" />

Media features are described in another section. The first sentence states:

Syntactically, media features resemble CSS properties: they have names and accept certain values.

So it only makes sense to describe error handling of the media features themselves first, then handling of their values.

于 2012-08-23T14:52:09.780 回答