CSSMediaRule interface represents a single CSS @media rule. It implements the CSSConditionRule interface, and therefore the CSSGroupingRule CSSRule interface with a type value of 4 ( CSSRule.MEDIA_RULE ).

句法

The syntax is described using the WebIDL 格式。

interface CSSMediaRule : CSSConditionRule {
    readonly attribute MediaList media;
}
					

特性

由于 CSSConditionRule , and therefore both a CSSGroupingRule CSSRule , CSSMediaRule also implements the properties of these interfaces. It has the following specific property:

CSSMediaRule.media 只读
Specifies a MediaList representing the intended destination medium for style information.

方法

由于 CSSConditionRule , and therefore both a CSSGroupingRule CSSRule , CSSMediaRule also implements the methods of that interface. It has no specific methods.

规范

规范 状态 注释
CSS Conditional Rules Module Level 3
The definition of 'CSSMediaRule' in that specification.
候选推荐 Make it derived from the CSSConditionRule .
CSS Object Model (CSSOM)
The definition of 'CSSMediaRule' in that specification.
工作草案 No changes from Document Object Model (DOM) Level 2 Style Specification
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSMediaRule' in that specification.
过时

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
CSSMediaRule Chrome 45 Edge ≤18 Firefox 17
17
Before Firefox 20, conditionText could not be set.
IE ? Opera Yes Safari Yes WebView Android 45 Chrome Android 45 Firefox Android 17
17
Before Firefox 20, conditionText could not be set.
Opera Android Yes Safari iOS Yes Samsung Internet Android 5.0
media Chrome Yes Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

见实现注意事项。

元数据

  • 最后修改: