blob: 6f83ef0b53b3ce92fd27aa81fba225a0202cd61b (
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
|
---
title: CSSRule.cssText
slug: Web/API/CSSRule/cssText
translation_of: Web/API/CSSRule/cssText
---
<div>
<div>{{ APIRef("CSSOM") }}</div>
</div>
<div> </div>
<div><span style="font-size: 2.14285714285714rem; font-weight: 700; letter-spacing: -1px; line-height: 30px;">概述</span></div>
<p><strong>cssText</strong> 返回样式规则所包含的实际文本.想要能够动态的设置一个样式表规则,查看<a href="/en-US/docs/DOM/Using_dynamic_styling_information" title="DOM/Using_dynamic_styling_information">使用动态样式信息.</a></p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><em>string</em> = cssRule.cssText
</pre>
<h2 id="Example" name="Example">例子</h2>
<pre class="brush:html;"><style>
body { background-color: darkblue; }
</style>
<script>
var stylesheet = document.styleSheets[0];
alert(stylesheet.cssRules[0].cssText); // body { background-color: darkblue; }
</script>
</pre>
<h2 id="Specification" name="Specification">规范</h2>
<ul>
<li><a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule">DOM Level 2 Style CSS - Interface CSSStyleRule (introduced in DOM Level 2)</a></li>
</ul>
|