aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/cssstylerule
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/cssstylerule
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/cssstylerule')
-rw-r--r--files/zh-cn/web/api/cssstylerule/index.html54
-rw-r--r--files/zh-cn/web/api/cssstylerule/selectortext/index.html33
-rw-r--r--files/zh-cn/web/api/cssstylerule/style/index.html43
3 files changed, 130 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstylerule/index.html b/files/zh-cn/web/api/cssstylerule/index.html
new file mode 100644
index 0000000000..9d3c7655a5
--- /dev/null
+++ b/files/zh-cn/web/api/cssstylerule/index.html
@@ -0,0 +1,54 @@
+---
+title: CSSStyleRule
+slug: Web/API/CSSStyleRule
+tags:
+ - API
+ - CSSOM
+ - 参考
+ - 接口
+translation_of: Web/API/CSSStyleRule
+---
+<div>{{ APIRef("CSSOM") }}</div>
+
+<p><strong><code>CSSStyleRule</code></strong> 表示一条 CSS 样式规则。它实现了 {{domxref("CSSRule")}} 接口,类型的值为 <code>1</code>(<code>CSSRule.STYLE_RULE</code>)。</p>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt id="selectorText">{{domxref("CSSStyleRule.selectorText")}}</dt>
+ <dd>返回这条规则的、文本格式的选择器,例如 <code>"h1,h2"</code>。</dd>
+ <dt id="style">{{domxref("CSSStyleRule.style")}} {{readonlyinline}}</dt>
+ <dd>返回这条规则的 {{domxref("CSSStyleDeclaration")}} 对象。</dd>
+ <dt>{{domxref("CSSStyleRule.styleMap")}} {{readonlyinline}}</dt>
+ <dd>返回一个 {{domxref('StylePropertyMap')}} 对象,which provides access to the rule's property-value pairs.</dd>
+</dl>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('CSSOM', '#the-cssstylerule-interface', 'CSSStyleRule') }}</td>
+ <td>{{ Spec2('CSSOM') }}</td>
+ <td>No changes</td>
+ </tr>
+ <tr>
+ <td>{{ SpecName('DOM2 Style', 'css.html#CSS-CSSStyleRule', 'CSSRule') }}</td>
+ <td>{{ Spec2('DOM2 Style') }}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.CSSStyleRule")}}</p>
diff --git a/files/zh-cn/web/api/cssstylerule/selectortext/index.html b/files/zh-cn/web/api/cssstylerule/selectortext/index.html
new file mode 100644
index 0000000000..76a9007cd3
--- /dev/null
+++ b/files/zh-cn/web/api/cssstylerule/selectortext/index.html
@@ -0,0 +1,33 @@
+---
+title: CSSStyleRule.selectorText
+slug: Web/API/CSSStyleRule/selectorText
+translation_of: Web/API/CSSStyleRule/selectorText
+---
+<div>{{APIRef("CSSOM") }}</div>
+
+<h2 id="Summary" name="Summary">概述</h2>
+
+<p><code><strong>CSSRule.selectorText</strong></code> 属性返回CSS规则的选择符文本,只读。动态设置CSS规则,请看 <a href="/en-US/docs/DOM/Using_dynamic_styling_information" title="/en-US/docs/DOM/Using_dynamic_styling_information">Using dynamic styling information</a>.</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><em>string</em> = cssRule.selectorText
+</pre>
+
+<h2 id="Example" name="Example">例子</h2>
+
+<pre class="brush: js">// for cssrule: body { background-color: darkblue; }
+var stylesheet = document.styleSheets[0];
+
+alert(stylesheet.cssRules[0].selectorText); // body
+</pre>
+
+<h2 class="Notes" id="说明">说明</h2>
+
+<p>浏览器解析选择符的时候可能会剔除不必要的空白字符</p>
+
+<h2 id="Specification" name="Specification">标准</h2>
+
+<ul>
+ <li><a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule" title="Document Object Model CSS #CSS-CSSRule">Document Object Model CSS - #CSS-CSSRuleCSS</a></li>
+</ul>
diff --git a/files/zh-cn/web/api/cssstylerule/style/index.html b/files/zh-cn/web/api/cssstylerule/style/index.html
new file mode 100644
index 0000000000..def2974719
--- /dev/null
+++ b/files/zh-cn/web/api/cssstylerule/style/index.html
@@ -0,0 +1,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>