CSSMediaRule.media
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.
media
は CSSMediaRule
インターフェイスの読み取り専用プロパティで、 MediaList
でスタイル情報の出力先メディアを表します。
値
MediaList
です。
例
この CSS には、単一のスタイルルールを持つメディアクエリーが含まれています。これは document.styleSheets[0].cssRules
が返す最初の CSSRule
になります。
したがって、 myRules[0].media
を呼び出すと、メディアクエリーを表す MediaList
オブジェクトを返します。
css
@media (min-width: 500px) {
body {
color: blue;
}
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].media); // a MediaList
仕様書
Specification |
---|
CSS Conditional Rules Module Level 3 # dom-cssmediarule-media |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
media |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.