getComputedStyleProperty()

介绍

Element 接口的 getComputedStyleProperty() 方法返回元素的指定计算样式

语法

const value = element.getComputedStyleProperty(styleName);

参数

styleName

指定要获取的属性名的字符串。样式名必须是 kebab-case

返回值

包含计算样式值的字符串。

示例

const width = element.getComputedStyleProperty('width');
const backgroundColor = element.getComputedStyleProperty('background-color');

兼容性

LCD tables only load in the browser

除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。