CSSMediaRule

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

CSSMediaRule 是一个表示单个CSS @media 规则的接口。它实现了 CSSConditionRule 接口,因此 CSSGroupingRuleCSSRule 接口类型值为 4CSSRule.MEDIA_RULE)。

语法

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

interface CSSMediaRule : CSSConditionRule {
    readonly attribute MediaList media;
}

属性

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

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

方法

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

规范

规范 状态 备注
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 YesFirefox 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 ?
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 ?

Legend

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

[1] Setting the value of conditionText on Gecko is only possible from Firefox 20 onwards.