Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten. Erfahre mehr über dieses Experiment.

View in English Always switch to English

CSSPositionTryRule

Limited availability

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

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

CSSRule CSSPositionTryRule

Instanz-Eigenschaften

Erbt Eigenschaften von seinem Vorfahren CSSRule.

CSSPositionTryRule.name Schreibgeschützt

Repräsentiert den Namen der Position-Try-Option, die von der @position-try At-Regel mit <dashed-ident> spezifiziert wird.

CSSPositionTryRule.style Schreibgeschützt

Ein CSSPositionTryDescriptors-Objekt, das die in der @position-try At-Regel festgelegten Deklarationen repräsentiert.

Instanz-Methoden

Keine spezifischen Methoden; erbt Methoden von seinem Vorfahren CSSRule.

Beispiele

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

css
@position-try --custom-left {
  position-area: left;
  width: 20%;
  max-width: 200px;
  margin-right: 10px;
}
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

Siehe auch