媒体查询有什么问题? [英] whats wrong with the media query?

查看:110
本文介绍了媒体查询有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

W3C标准文档说:


当某个媒体功能未知时,用户代理将媒体查询表示为不是全部。

User agents are to represent a media query as "not all" when one of the specified media features is not known.

然后它给出以下示例:

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

然后说,第一个媒体查询将被表示为不是全部第二媒体查询被评估为好像没有指定第一媒体查询。

It then says that the first media query will be represented as "not all" and evaluate to false and the second media query is evaluated as if the first had not been specified, effectively.

为什么这样。我希望这是因为3kg的max-weight值不是有效的值,这在doc中没有解释作为一个原因。然而,我不能看到任何未知的媒体功能,但未知的媒体功能价值,这是在未知的媒体功能之后的文档中单独讨论。我认为此示例应该放在未知媒体功能值下,但不在未知媒体功能中。

Why is it like that. I hope that's because 3kg value for max-weight is not the valid value, which is not explained in doc as a reason. However I cant see any unknown media-feature but "Unknown media feature value", which is discussed separately in the document just after "Unknown media features". I think this example should have been put below "Unknown media feature value" but not in "Unknown media features".

推荐答案

该示例指向的未知媒体特征是 max-weight 。一旦遇到这种情况, 3kg 值就不再相关,因为它永远不会适用,因为浏览器不知道如何处理 max-weight 。因此,它会完全跳过该媒体查询,让您有效地使用以下内容:

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" />

与以下内容相同:

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

媒体功能在另一部分。第一句话说:

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


在语法上,媒体特性类似于CSS属性:它们有名称并接受某些值。

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.

这篇关于媒体查询有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆