aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue')
-rw-r--r--files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue/index.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue/index.html b/files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue/index.html
new file mode 100644
index 0000000000..c5eff00183
--- /dev/null
+++ b/files/zh-cn/web/api/cssstyledeclaration/getpropertyvalue/index.html
@@ -0,0 +1,71 @@
+---
+title: CSSStyleDeclaration.getPropertyValue()
+slug: Web/API/CSSStyleDeclaration/getPropertyValue
+tags:
+ - CSSOM
+ - Reference
+ - getComputedStyle
+ - getPropertyValue
+ - setProperty
+ - 参考
+ - 方法
+ - 标签
+translation_of: Web/API/CSSStyleDeclaration/getPropertyValue
+---
+<p>{{ APIRef("CSSOM") }}</p>
+
+<p><strong>CSSStyleDeclaration.getPropertyValue()</strong> 接口返回一个 {{domxref('DOMString')}} ,其中包含请求的CSS属性的值。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var <em>value</em> = <em>style</em>.getPropertyValue(<em>property</em>);</pre>
+
+<h3 id="参数">参数</h3>
+
+<ul>
+ <li><em><code>property</code></em> 是一个 {{domxref('DOMString')}},是需要查询的CSS 属性名称。</li>
+</ul>
+
+<h3 id="返回值">返回值</h3>
+
+<ul>
+ <li><code><em>value</em></code> 是 {{domxref('DOMString')}} ,包含查找属性的值。若对应属性没有设置,则返回空字符串。</li>
+</ul>
+
+<h2 id="示例">示例</h2>
+
+<p>下述示例使用一个CSS选择器规则查询对应的<code>margin</code> 属性的值:</p>
+
+<pre class="brush: js">var declaration = document.styleSheets[0].cssRules[0].style;
+var value = declaration.getPropertyValue('margin'); // "1px 2px"
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSSOM', '#dom-cssstyledeclaration-getpropertyvalue', 'CSSStyleDeclaration.getPropertyValue()')}}</td>
+ <td>{{Spec2('CSSOM')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}}</td>
+ <td>{{Spec2('DOM2 Style')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性"><strong>浏览器兼容性</strong></h2>
+
+<p>{{Compat("api.CSSStyleDeclaration.getPropertyValue")}}</p>
+
+<div id="compat-mobile"></div>