--- title: CSSStyleDeclaration.getPropertyCSSValue() slug: Web/API/CSSStyleDeclaration/getPropertyCSSValue tags: - CSSOM - Obsolete - Reference translation_of: Web/API/CSSStyleDeclaration/getPropertyCSSValue ---
{{ APIRef("CSSOM") }} {{Obsolete_header}}
CSSStyleDeclaration.getPropertyCSSValue() 方法接口返回一个{{domxref('CSSValue')}} 包含一个属性的CSS值。请注意,如果属性名称是速记属性,则返回null。
现在你应该使用 {{domxref("CSSStyleDeclaration.getPropertyValue()")}}。
let value = style.getPropertyCSSValue(property);
property
is a {{domxref('DOMString')}} representing the property name to be retrieved.value
is a {{domxref('CSSValue')}} containing the CSS value for a property. If none exists, returns null
.The following JavaScript code gets an object containing the computed RGB values of the color
CSS property:
var style = window.getComputedStyle(elem, null); var rgbObj = style.getPropertyCSSValue('color').getRGBColorValue();
Specification | Status | Comment |
---|---|---|
{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}} | {{Spec2('DOM2 Style')}} | Declared as obsolete in July 2003. |
{{Compat("api.CSSStyleDeclaration.getPropertyCSSValue")}}