CSSPositionTryRule

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.

Das CSSPositionTryRule-Interface beschreibt ein Objekt, das eine @position-try At-Regel repräsentiert.

CSSRule CSSPositionTryRule

Instanz-Eigenschaften

Erbt Eigenschaften von seinem Vorgänger CSSRule.

CSSPositionTryRule.name Schreibgeschützt Experimentell

Stellt den Namen der Position-Try-Option dar, die von der @position-try-At-Regel durch deren <dashed-ident> angegeben wird.

CSSPositionTryRule.style Schreibgeschützt Experimentell

Ein CSSPositionTryDescriptors-Objekt, das die Deklarationen repräsentiert, die im Body der @position-try-At-Regel definiert wurden.

Instanz-Methoden

Keine spezifischen Methoden; erbt Methoden von seinem Vorgänger CSSRule.

Beispiele

Das CSS enthält eine @position-try-At-Regel mit einem Namen von --custom-left und drei Deskriptoren.

css
@position-try --custom-left {
  position-area: left;
  width: 20%;
  max-width: 200px;
  margin: 0 10px 0 0;
}
js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption); // "[object CSSPositionTryRule]"
console.log(tryOption.name); // "--custom-left"
console.log(tryOption.style); // "[object CSSPositionTryDescriptors]"
console.log(tryOption.style.maxWidth); // "200px"

Spezifikationen

Specification
CSS Anchor Positioning
# csspositiontryrule

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
CSSPositionTryRule
Experimental
name
Experimental
style
Experimental

Legend

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

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.

Siehe auch