For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/lynx-api/main-thread/element-get-computed-style.md.
Lynx
  • 简体中文
  • 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 许可协议进行许可。