CSSImportRule

Baseline Widely available *

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

* Some parts of this feature may have varying levels of support.

Giao diện CSSImportRule đại diện cho quy tắc điều kiện @import.

CSSRule CSSImportRule

Thuộc tính instance

Kế thừa các thuộc tính từ tổ tiên CSSRule.

CSSImportRule.href Read only

Trả về URL được chỉ định bởi quy tắc @import.

CSSImportRule.layerName Read only

Trả về tên của tầng cascade được khai báo trong quy tắc @import, chuỗi rỗng nếu tầng là ẩn danh, hoặc null nếu quy tắc không khai báo bất kỳ tầng nào.

CSSImportRule.media

Trả về giá trị của thuộc tính media của bảng kiểu liên kết.

CSSImportRule.styleSheet Read only

Trả về bảng kiểu liên kết.

CSSImportRule.supportsText Read only

Trả về điều kiện supports được chỉ định bởi quy tắc @import.

Phương thức instance

Kế thừa các phương thức từ tổ tiên CSSRule.

Ví dụ

Tài liệu bao gồm một bảng kiểu duy nhất chứa một quy tắc @import duy nhất. Do đó, mục đầu tiên trong danh sách các quy tắc CSS sẽ là một CSSImportRule.

css
@import "style.css" screen;
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // Một đối tượng instance CSSImportRule

Đặc tả kỹ thuật

Specification
CSS Object Model (CSSOM)
# the-cssimportrule-interface

Tương thích trình duyệt