-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
49 lines (35 loc) · 1.69 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: CSSStyleRule.style
slug: Web/API/CSSStyleRule/style
l10n:
sourceCommit: bf30e32f3b51f59080f2c76795beadb247a551eb
---
{{ APIRef("CSSOM") }}
**`style`** は読み取り専用プロパティで、この {{ DOMXref("CSSStyleRule") }} の[宣言ブロック](https://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#block)のための {{ domxref("CSSStyleDeclaration") }} インターフェイスです。
## 値
{{domxref("CSSStyleDeclaration")}} オブジェクトで、次のプロパティがあります。
- computed flag
- : 未設定。
- declarations
- : このルール内で宣言された宣言で、指定された順番であり、個別指定プロパティに展開された一括指定プロパティです。
- parent CSS rule
- : コンテキストオブジェクトで、 [this](https://heycam.github.io/webidl/#this) の別名です。
- owner node
- : null です。
## 例
この CSS は 1 つのスタイルルールを含んでいます。これは最初の {{domxref("CSSRule")}} となり、 `document.styleSheets[0].cssRules` で返されます。
従って、 `myRules[0].style` は `h1` に定義された宣言を表す {{domxref("CSSStyleDeclaration")}} をを返します。
```css
h1 {
color: pink;
}
```
```js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].style); // a CSSStyleDeclaration representing the declarations on the h1.
```
> **メモ:** 宣言ブロックは、中括弧内に現れるスタイルルールの一部で、実際にスタイル定義を提供する部分です(セレクターについては、中括弧の前に来る部分)。
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}