--- title: DocumentOrShadowRoot.styleSheets slug: Web/API/Document/styleSheets translation_of: Web/API/DocumentOrShadowRoot/styleSheets original_slug: Web/API/DocumentOrShadowRoot/styleSheets ---
styleSheets是{{domxref("DocumentOrShadowRoot")}}接口定义的只读属性,它会返回一个{{domxref('StyleSheetList')}} / {{domxref('CSSStyleSheet')}} 对象,这个对象对应的是通过引入或者嵌入文档中的样式表。
function getStyleSheet(unique_title) {
for (var i=0; i<document.styleSheets.length; i++) {
var sheet = document.styleSheets[i];
if (sheet.title == unique_title) {
return sheet;
}
}
}
返回的列表中,排序规则如下:
| 规范 | 状态 | 说明 |
|---|---|---|
| {{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}} | {{Spec2('Shadow DOM')}} | Initial definition. |
{{Compat("api.DocumentOrShadowRoot.styleSheets")}}