CSSMediaRule

CSSMediaRule 是一个表示单个CSS @media 规则的接口。它实现了 CSSConditionRule 接口,因此也是 CSSGroupingRule,也相当于CSSRule中类型值为 4 的规则类型(即CSSRule.MEDIA_RULE)。

语法

下列语法是使用 WebIDL 格式描述的。

interface CSSMediaRule : CSSConditionRule {
    readonly attribute MediaList media;
}

属性

作为一个 CSSConditionRule,同时也是 CSSGroupingRuleCSSRuleCSSMediaRule 也实现(继承)了来自这些接口的属性。它还有如下属性:

CSSMediaRule.media 只读
声明了一个 MediaList,表示指定目标媒体中的样式信息。

方法

作为一个 CSSConditionRule,同时也是 CSSGroupingRuleCSSRuleCSSMediaRule 也实现(继承)了来自这些接口的方法。除此之外,没有其他方法。

规范

规范 状态 备注
CSS Conditional Rules Module Level 3
CSSMediaRule
Candidate Recommendation Make it derived from the CSSConditionRule.
CSS Object Model (CSSOM)
CSSMediaRule
Working Draft No changes from Document Object Model (DOM) Level 2 Style Specification
Document Object Model (DOM) Level 2 Style Specification
CSSMediaRule
Obsolete

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
CSSMediaRuleChrome Full support 45Edge Full support ≤18Firefox Full support 17
Notes
Full support 17
Notes
Notes Before Firefox 20, conditionText could not be set.
IE ? Opera Full support YesSafari Full support YesWebView Android Full support 45Chrome Android Full support 45Firefox Android Full support 17
Notes
Full support 17
Notes
Notes Before Firefox 20, conditionText could not be set.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 5.0
mediaChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.