We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Перевод не завершен. Пожалуйста, помогите перевести эту статью с английского.

Summary

CSSStyleDeclaration represents a collection of CSS property-value pairs. It is used in a few APIs:

Attributes

CSSStyleDeclaration.cssText
Textual representation of the declaration block. Setting this attribute changes the style.
CSSStyleDeclaration.length Только для чтения
The number of properties. See the item() method below.
CSSStyleDeclaration.parentRule Только для чтения
The containing CSSRule.

Методы

CSSStyleDeclaration.getPropertyPriority()
Returns the optional priority, "important".
CSSStyleDeclaration.getPropertyValue()
Returns the property value given a property name.
CSSStyleDeclaration.item()
Returns a property name.
CSSStyleDeclaration.removeProperty()
Removes a property from the CSS declaration block.
CSSStyleDeclaration.setProperty()
Modifies an existing CSS property or creates a new CSS property in the declaration block/.
CSSStyleDeclaration.getPropertyCSSValue()
Only supported via getComputedStyle in Firefox. Returns the property value as a 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);

Notes

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).

See also

Specifications

Specification Status Comment
CSS Object Model (CSSOM)
Определение 'CSSStyleDeclaration' в этой спецификации.
Рабочий черновик  
Document Object Model (DOM) Level 2 Style Specification
Определение 'CSSPrimitiveValue' в этой спецификации.
Устаревшая Initial definition

Метки документа и участники

Внесли вклад в эту страницу: ildar_ibragimov, Sebastianz
Обновлялась последний раз: ildar_ibragimov,