此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

StyleSheet:parentStyleSheet 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

StyleSheet 接口的 parentStyleSheet 属性返回样式表(如果有),其中包含给定的样式表。

一个 StyleSheet 对象。

示例

js
// 查找顶级样式表
const sheet = stylesheet.parentStyleSheet ?? stylesheet;

备注

如果当前样式表是一个顶级的样式表或者如果不支持包含样式表,则这个属性返回 null

规范

Specification
CSS Object Model (CSSOM)
# dom-stylesheet-parentstylesheet

浏览器兼容性