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.

Das CSSSupportsRule-Interface repräsentiert eine einzelne CSS-@supports-At-Regel.

CSSRule CSSGroupingRule CSSConditionRule CSSSupportsRule

Instanzeigenschaften

Erbt Eigenschaften von seinen Vorfahren CSSConditionRule, CSSGroupingRule, und CSSRule.

Instanzmethoden

Erbt Methoden von seinen Vorfahren CSSConditionRule, CSSGroupingRule, und CSSRule.

Beispiele

Das CSS enthält eine CSS-Feature-Abfrage mit der @supports-At-Regel, die eine einzige Stilregel beinhaltet. Dies wird die erste CSSRule sein, die durch document.styleSheets[0].cssRules zurückgegeben wird. myRules[0] gibt daher ein CSSSupportsRule-Objekt zurück.

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

Spezifikationen

Specification
CSS Conditional Rules Module Level 3
# the-csssupportsrule-interface

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CSSSupportsRule

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.

Siehe auch