From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/zh-tw/web/api/cssstyledeclaration/index.html | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/zh-tw/web/api/cssstyledeclaration/index.html (limited to 'files/zh-tw/web/api/cssstyledeclaration/index.html') diff --git a/files/zh-tw/web/api/cssstyledeclaration/index.html b/files/zh-tw/web/api/cssstyledeclaration/index.html new file mode 100644 index 0000000000..8893e225d6 --- /dev/null +++ b/files/zh-tw/web/api/cssstyledeclaration/index.html @@ -0,0 +1,90 @@ +--- +title: CSSStyleDeclaration +slug: Web/API/CSSStyleDeclaration +translation_of: Web/API/CSSStyleDeclaration +--- +

{{ APIRef("CSSOM") }}

+ +

概要

+ +

CSSStyleDeclaration 表示了一個 CSS 屬性名值對(property-value pairs)的集合。它被用於幾個 API 當中:

+ + + +

屬性

+ +
+
{{domxref("CSSStyleDeclaration.cssText")}}
+
Textual representation of the declaration block. Setting this attribute changes the style.
+
{{domxref("CSSStyleDeclaration.length")}} {{readonlyInline}}
+
The number of properties. See the {{domxref("CSSStyleDeclaration.item", 'item()')}} method below.
+
{{domxref("CSSStyleDeclaration.parentRule")}} {{readonlyInline}}
+
The containing {{domxref("CSSRule")}}.
+
+ +

方法

+ +
+
{{domxref("CSSStyleDeclaration.getPropertyPriority()")}}
+
Returns the optional priority, "important".
+
{{domxref("CSSStyleDeclaration.getPropertyValue()")}}
+
Returns the property value given a property name.
+
{{domxref("CSSStyleDeclaration.item()")}}
+
Returns a property name.
+
{{domxref("CSSStyleDeclaration.removeProperty()")}}
+
Removes a property from the CSS declaration block.
+
{{domxref("CSSStyleDeclaration.setProperty()")}}
+
Modifies an existing CSS property or creates a new CSS property in the declaration block/.
+
{{domxref("CSSStyleDeclaration.getPropertyCSSValue()")}} {{obsolete_inline}}
+
Only supported via getComputedStyle in Firefox. Returns the property value as a {{ domxref("CSSPrimitiveValue") }} or null for shorthand properties.
+
+ +

範例

+ +
var styleObj = document.styleSheets[0].cssRules[0].style;
+console.log(styleObj.cssText);
+
+for (var i = styleObj.length; i--;) {
+  var nameString = styleObj[i];
+  styleObj.removeProperty(nameString);
+}
+
+console.log(styleObj.cssText);
+ +

備註

+ +

The declaration block is that part of the style rule that appears within the braces and that actually provides the style definitions (for the selector, the part that comes before the braces).

+ +

參見

+ + + +

規範

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSSOM', '#the-cssstyledeclaration-interface', 'CSSStyleDeclaration')}}{{Spec2('CSSOM')}} 
{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSPrimitiveValue')}}{{Spec2('DOM2 Style')}}Initial definition
-- cgit v1.2.3-54-g00ecf