Skip to main content

media-feature-name-value-allowed-list

指定允许的媒体功能名称和值对的列表。

¥Specify a list of allowed media feature name and value pairs.

@media screen and (min-width: 768px) {}
/** ↑ ↑

* These features and values */

message 次要选项 可以接受该规则的参数。

¥The message secondary option can accept the arguments of this rule.

选项

¥Options

object{ "unprefixed-media-feature-name": ["array", "of", "values", "/regex/", /regex/]|"value"|"/regex/"|/regex/ }

如果在对象中找到媒体功能名称,则仅允许其允许列出的值。如果对象中不包含媒体功能名称,则一切正常。

¥If a media feature name is found in the object, only its allowed-listed values are allowed. If the media feature name is not included in the object, anything goes.

如果名称或值被 / 包围(例如 "/width$/"),则它被解释为正则表达式。例如,/width$/ 将匹配 max-widthmin-width

¥If a name or value is surrounded with / (e.g. "/width$/"), it is interpreted as a regular expression. For example, /width$/ will match max-width and min-width.

鉴于:

¥Given:

{
"min-width": ["768px", "1024px"],
"/resolution/": "/dpcm$/"
}

以下模式被视为问题:

¥The following patterns are considered problems:

@media screen and (min-width: 1000px) {}
@media screen and (min-resolution: 2dpi) {}
@media screen and (min-width > 1000px) {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@media screen and (min-width: 768px) {}
@media screen and (min-width: 1024px) {}
@media screen and (orientation: portrait) {}
@media screen and (min-resolution: 2dpcm) {}
@media screen and (resolution: 10dpcm) {}
@media screen and (768px < min-width) {}