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: style-Eigenschaft

Limited availability

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

Die schreibgeschützte style-Eigenschaft der CSSPositionTryRule-Schnittstelle enthält ein CSSPositionTryDescriptors-Objekt, das die in der @position-try-Regel verfügbaren Deskriptoren darstellt.

Wert

Ein CSSPositionTryDescriptors-Objekt.

Obwohl die style-Eigenschaft selbst im Sinne eines Austauschs des CSSPositionTryDescriptors-Objekts schreibgeschützt ist, können Sie der style-Eigenschaft direkt Werte zuweisen, was gleichbedeutend mit einer Zuweisung an ihre cssText-Eigenschaft ist. Sie können auch das CSSPositionTryDescriptors-Objekt mit den Methoden setProperty() und removeProperty() modifizieren.

Beispiele

Das CSS enthält eine @position-try-Regel mit dem Namen --custom-right und drei Deskriptoren.

css
@position-try --custom-bottom {
  top: anchor(bottom);
  min-width: 100px;
  margin-top: 10px;
}
js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption.style.top); // "anchor(bottom)"
console.log(tryOption.style["min-width"]); // "100px"
console.log(tryOption.style.positionArea); // ""; no position-area specified

Spezifikationen

Specification
CSS Anchor Positioning
# dom-csspositiontryrule-style

Browser-Kompatibilität

Siehe auch