blob: 732ae8229cc25bf2859f5a13d723cce2c75b69e8 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
---
title: CSSStyleDeclaration.getPropertyCSSValue()
slug: Web/API/CSSStyleDeclaration/getPropertyCSSValue
tags:
- CSSOM
- Obsolete
- Reference
translation_of: Web/API/CSSStyleDeclaration/getPropertyCSSValue
---
<p>{{ APIRef("CSSOM") }} {{Obsolete_header}}</p>
<p><strong>CSSStyleDeclaration.getPropertyCSSValue()</strong> 方法接口返回一个{{domxref('CSSValue')}} 包含一个属性的CSS值。请注意,如果属性名称是速记属性,则返回null。</p>
<p>现在你应该使用 {{domxref("CSSStyleDeclaration.getPropertyValue()")}}。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">let <em>value</em> = <em>style</em>.getPropertyCSSValue(<em>property</em>);</pre>
<h3 id="参数">参数</h3>
<ul>
<li><em><code>property</code></em> is a {{domxref('DOMString')}} representing the property name to be retrieved.</li>
</ul>
<h3 id="返回值">返回值</h3>
<ul>
<li><code><em>value</em></code> is a {{domxref('CSSValue')}} containing the CSS value for a property. If none exists, returns <code>null</code>.</li>
</ul>
<h2 id="示例">示例</h2>
<p>The following JavaScript code gets an object containing the computed RGB values of the <code>color</code> CSS property:</p>
<pre class="brush: js">var style = window.getComputedStyle(elem, null);
var rgbObj = style.getPropertyCSSValue('color').getRGBColorValue();
</pre>
<h2 id="规范">规范</h2>
<table>
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}}</td>
<td>{{Spec2('DOM2 Style')}}</td>
<td>Declared as obsolete in <a href="https://lists.w3.org/Archives/Public/www-style/2003Oct/0347.html">July 2003</a>.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性"><strong>浏览器兼容性</strong></h2>
<p>{{Compat("api.CSSStyleDeclaration.getPropertyCSSValue")}}</p>
|