CSSPositionTryRule: style-Eigenschaft
Baseline
2026
Newly available
Since January 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or 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.
@position-try --custom-bottom {
top: anchor(bottom);
min-width: 100px;
margin-top: 10px;
}
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 Module Level 1> # dom-csspositiontryrule-style> |