blob: def29747193155627041960e2b1387ec583995b3 (
plain)
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
|
---
title: style
slug: Web/API/CSSStyleRule/style
translation_of: Web/API/CSSStyleRule/style
---
<p>{{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">概述</h3>
<p>返回 一个 {{ domxref("CSSStyleDeclaration") }}接口对象,它代表了{{ DOMXref("CSSRule") }}的 <a class="external" href="http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#block">declaration block</a>。</p>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="eval notranslate"><em>styleObj</em> = <em>cssRule</em>.style
</pre>
<h3 id="Example" name="Example">例子</h3>
<pre class="brush: js notranslate">function stilo() {
alert(document.styleSheets[0].cssRules[0].style.cssText);
}
// 弹出 "background-color: gray;"
</pre>
<h3 id="Notes" name="Notes">备注</h3>
<p>declaration block是样式规则中花括号内的部分(选择器就在花括号的外部)</p>
<h3 id="相关链接">相关链接</h3>
<ul>
<li><a href="/zh-cn/CSS/CSS_Reference" title="zh-cn/DOM/CSS">DOM CSS Properties</a></li>
</ul>
<h3 id="Specification" name="Specification">规范</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleRule-style">DOM Level 2 CSS: style</a></p>
<p>{{ languages( {"en": "en/DOM/CSSStyleRule/style" } ) }}</p>
<h3 id="Specification" name="Specification">浏览器兼容性</h3>
<p>{{Compat("api.CSSStyleRule.style")}}</p>
|