CSSMediaRule
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
CSSMediaRule
は、単一の CSS の @media
ルールを表すインターフェイスです。
プロパティ
祖先である CSSConditionRule
、CSSGroupingRule
、CSSRule
から継承したプロパティもあります。
CSSMediaRule.media
読取専用-
スタイル情報の出力先メディアを表す
MediaList
を返します。
メソッド
固有のメソッドはありません。祖先である CSSConditionRule
、CSSGroupingRule
、CSSRule
から継承したメソッドがあります。
例
この CSS には、単一のスタイルルールを持つメディアクエリーが含まれています。これは document.styleSheets[0].cssRules
が返す最初の CSSRule になります。
したがって、 myRules[0]
は CSSMediaRule
オブジェクトを返します。
css
@media (min-width: 500px) {
body {
color: blue;
}
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // a CSSMediaRule representing the media query.
仕様書
Specification |
---|
CSS Conditional Rules Module Level 3 # the-cssmediarule-interface |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
CSSMediaRule | ||||||||||||
media |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
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.