CSSSupportsRule

Baseline Widely available

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

Giao diện CSSSupportsRule đại diện cho một CSS at-rule @supports đơn lẻ.

CSSRule CSSGroupingRule CSSConditionRule CSSSupportsRule

Thuộc tính phiên bản

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

Phương thức phiên bản

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

Ví dụ

CSS bao gồm một feature query CSS sử dụng at-rule @supports, chứa một quy tắc kiểu. Đây sẽ là CSSRule đầu tiên được trả về bởi document.styleSheets[0].cssRules. myRules[0] do đó trả về đối tượng CSSSupportsRule.

css
@supports (display: grid) {
  body {
    color: blue;
  }
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // a CSSSupportsRule representing the feature query.

Thông số kỹ thuật

Thông số kỹ thuật
CSS Conditional Rules Module Level 3
# the-csssupportsrule-interface

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

Xem thêm