CSSPositionTryDescriptors
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheCSSPositionTryDescriptors interface defines properties that represent the list of CSS descriptors that can be set in the body of a@position-tryat-rule.
Each descriptor in the body of the corresponding@position-try at-rule can be accessed using either its property name inbracket notation or the camel-case version of the property name "propertyName" indot notation.For example, you can access the CSS property "property-name" asstyle["property-name"] orstyle.propertyName, wherestyle is aCSSPositionTryDescriptors instance.A property with a single-word name likeheight can be accessed using either notation:style["height"] orstyle.height.
Note:TheCSSPositionTryRule interface represents a@position-try at-rule, and theCSSPositionTryRule.style property is an instance of this object.
In this article
Instance properties
Inherits properties from its ancestorCSSStyleDeclaration.
The following property names, in snake-case (accessed using bracket notation) and camel-case (accessed using dot notation), each represent the value of a descriptor in the corresponding@position-try at-rule:
align-selforalignSelfA string representing the value of an
align-selfdescriptor.block-sizeorblockSizeA string representing the value of a
block-sizedescriptor.bottomA string representing the value of a
bottomdescriptor.heightA string representing the value of a
heightdescriptor.inline-sizeorinlineSizeA string representing the value of an
inline-sizedescriptor.insetA string representing the value of an
insetdescriptor.position-areaorpositionAreaA string representing the value of a
position-areadescriptor.inset-blockorinsetBlockA string representing the value of an
inset-blockdescriptor.inset-block-endorinsetBlockEndA string representing the value of an
inset-block-enddescriptor.inset-block-startorinsetBlockStartA string representing the value of an
inset-block-startdescriptor.inset-inlineorinsetInlineA string representing the value of an
inset-inlinedescriptor.inset-inline-endorinsetInlineEndA string representing the value of an
inset-inline-enddescriptor.inset-inline-startorinsetInlineStartA string representing the value of an
inset-inline-startdescriptor.justify-selforjustifySelfA string representing the value of a
justify-selfdescriptor.leftA string representing the value of a
leftdescriptor.marginA string representing the value of a
margindescriptor.margin-blockormarginBlockA string representing the value of a
margin-blockdescriptor.margin-block-endormarginBlockEndA string representing the value of a
margin-block-enddescriptor.margin-block-startormarginBlockStartA string representing the value of a
margin-block-startdescriptor.margin-bottomormarginBottomA string representing the value of a
margin-bottomdescriptor.margin-inlineormarginInlineA string representing the value of a
margin-inlinedescriptor.margin-inline-endormarginInlineEndA string representing the value of a
margin-inline-enddescriptor.margin-inline-startormarginInlineStartA string representing the value of a
margin-inline-startdescriptor.margin-leftormarginLeftA string representing the value of a
margin-leftdescriptor.margin-rightormarginRightA string representing the value of a
margin-rightdescriptor.margin-topormarginTopA string representing the value of a
margin-topdescriptor.max-block-sizeormaxBlockSizeA string representing the value of a
max-block-sizedescriptor.max-heightormaxHeightA string representing the value of a
max-heightdescriptor.max-inline-sizeormaxInlineSizeA string representing the value of a
max-inline-sizedescriptor.max-widthormaxWidthA string representing the value of a
max-widthdescriptor.min-block-sizeorminBlockSizeA string representing the value of a
min-block-sizedescriptor.min-heightorminHeightA string representing the value of a
min-heightdescriptor.min-inline-sizeorminInlineSizeA string representing the value of a
min-inline-sizedescriptor.min-widthorminWidthA string representing the value of a
min-widthdescriptor.place-selforplaceSelfA string representing the value of a
place-selfdescriptor.position-anchororpositionAnchorA string representing the value of a
position-anchordescriptor.rightA string representing the value of a
rightdescriptor.topA string representing the value of a
topdescriptor.widthA string representing the value of a
widthdescriptor.
Instance methods
No specific methods; inherits methods from its ancestorCSSStyleDeclaration.
Examples
The CSS includes a@position-try at-rule with a name of--custom-right and three descriptors.
@position-try --custom-right { position-area: right; width: 100px; margin-left: 10px;}const myRules = document.styleSheets[0].cssRules;const tryOption = myRules[0]; // a CSSPositionTryRuleconsole.log(tryOption.style); // "[object CSSPositionTryDescriptors]"console.log(tryOption.style.margin); // "0 0 0 10px"console.log(tryOption.style["position-area"]); // "right"Specifications
| Specification |
|---|
| CSS Anchor Positioning> # csspositiontrydescriptors> |