Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial review: CSS anchor positioning 5: position try functionality #33609

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bbd9ff7
Add position-try-options ref page
chrisdavidmills May 14, 2024
c3fed25
Add inset-area() function page
chrisdavidmills May 15, 2024
eba1966
Add position-try ref page
chrisdavidmills May 15, 2024
b0d56f1
Add @position-try ref page
chrisdavidmills May 15, 2024
f1c980a
Add position-try-order and CSSOM pages
chrisdavidmills May 16, 2024
8ff430d
Merge branch 'main' into css-anchor-positioning-5
chrisdavidmills May 16, 2024
0dc91ca
Merge branch 'main' into css-anchor-positioning-5
chrisdavidmills May 20, 2024
9f1ea3c
Fixes for mfreed7 review comments
chrisdavidmills May 20, 2024
da8bee9
Merge branch 'main' into css-anchor-positioning-5
chrisdavidmills May 21, 2024
e3dfe81
Pertial fix for the review comments so far
chrisdavidmills May 27, 2024
105ac53
Fixes made for rest of estelle comments so far
chrisdavidmills May 28, 2024
37cfbac
Merge branch 'main' into css-anchor-positioning-5
chrisdavidmills May 28, 2024
41fa51c
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
873556c
Update files/en-us/web/css/@position-try/index.md
chrisdavidmills May 28, 2024
aaf8922
Update files/en-us/web/css/@position-try/index.md
chrisdavidmills May 28, 2024
358717d
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
7feac15
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
b1b48fd
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
9a7159d
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
9bb621e
Update files/en-us/web/css/@position-try/index.md
chrisdavidmills May 28, 2024
b4aa225
Update files/en-us/web/api/csspositiontrydescriptors/index.md
chrisdavidmills May 28, 2024
621a4a4
Run prettier to fix linter errors
chrisdavidmills May 28, 2024
5e8d083
Update anchor names to be more distinct and less confusing
chrisdavidmills May 31, 2024
1560f65
Get around weird syntax linter behavior
chrisdavidmills May 31, 2024
b07942d
Update wording and casing for reference links
chrisdavidmills May 31, 2024
265901a
close js
estelle Jun 4, 2024
7b3c65d
remove tick marks
estelle Jun 4, 2024
831334d
Apply suggestions from code review
estelle Jun 4, 2024
205b259
Merge branch 'main' into css-anchor-positioning-5
chrisdavidmills Jun 5, 2024
9806000
Fixes for estelle review comments
chrisdavidmills Jun 5, 2024
b86c777
Update files/en-us/web/css/position-try-order/index.md
chrisdavidmills Jun 5, 2024
3642808
update @position-try example to include inset options
chrisdavidmills Jun 11, 2024
a8c2db9
Update files/en-us/web/css/@position-try/index.md
chrisdavidmills Jun 11, 2024
8b3ce0b
Update syntax section for consistency
chrisdavidmills Jun 14, 2024
e0fbe01
Add <try-size> type to position-try-order page
chrisdavidmills Jun 14, 2024
7e71b29
improve see alsos
chrisdavidmills Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions files/en-us/web/api/css_object_model/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ The values of CSS are represented untyped, that is using {{JSxRef("String")}} ob
- {{DOMxRef("CSSMediaRule")}}
- {{DOMxRef("CSSNamespaceRule")}}
- {{DOMxRef("CSSPageRule")}}
- {{DOMxRef("CSSPositionTryRule")}}
- {{DOMxRef("CSSPositionTryDescriptors")}}
- {{DOMxRef("CSSRule")}}
- {{DOMxRef("CSSRuleList")}}
- {{DOMxRef("CSSStartingStyleRule")}}
- {{DOMxRef("CSSStyleDeclaration")}}
- {{DOMxRef("CSSStyleSheet")}}
- {{DOMxRef("CSSStyleRule")}}
Expand Down
112 changes: 112 additions & 0 deletions files/en-us/web/api/csspositiontrydescriptors/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: CSSPositionTryDescriptors
estelle marked this conversation as resolved.
Show resolved Hide resolved
slug: Web/API/CSSPositionTryDescriptors
page-type: web-api-interface
status:
- experimental
browser-compat: api.CSSPositionTryDescriptors
---

{{APIRef("CSSOM")}}

The **`CSSPositionTryDescriptors`** interface describes an object representing a {{cssxref("@position-try")}} [at-rule](/en-US/docs/Web/CSS/At-rule).

{{InheritanceDiagram}}

## Instance properties

_Inherits properties from its ancestor {{domxref("CSSStyleDeclaration")}}._

The `CSSPositionTryDescriptors` interface defines properties that represent the [CSS properties that can be set inside a `@position-try` at rule](/en-US/docs/Web/CSS/@position-try#declaration-list).

There are 35 CSS properties that can be accessed as CSS property names or camel-case. For each one:

- `CSSPositionTryDescriptors.propertyName`
- : Represents the property value set in the `@position-try` at-rule using the camel-cased property name.
- `CSSPositionTryDescriptors["property-name"]`
- : Represents the property value set in the `@position-try` at-rule using the CSS property name.

The instance properties are listed below:

| CSS&nbsp;property | Camel-case | Property name |
| ---------------------------------- | --------------------------------------------- | -------------------------------------------------- |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we start off with a const CSSPTD = CSSPositionTryDescriptors, so we can shorten the table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think that would just make it more confusing

| {{cssxref("align-self")}} | `CSSPositionTryDescriptors.alignSelf` | `CSSPositionTryDescriptors["align-self"]` |
| {{cssxref("block-size")}} | `CSSPositionTryDescriptors.blockSize` | `CSSPositionTryDescriptors["block-size"]` |
| {{cssxref("bottom")}} | `CSSPositionTryDescriptors.bottom` | `CSSPositionTryDescriptors["bottom"]` |
| {{cssxref("height")}} | `CSSPositionTryDescriptors.height` | `CSSPositionTryDescriptors["height"]` |
| {{cssxref("inline-size")}} | `CSSPositionTryDescriptors.inlineSize` | `CSSPositionTryDescriptors["inline-size"]` |
| {{cssxref("inset")}} | `CSSPositionTryDescriptors.inset` | `CSSPositionTryDescriptors["inset"]` |
| {{cssxref("inset-area")}} | `CSSPositionTryDescriptors.insetArea` | `CSSPositionTryDescriptors["inset-area"]` |
| {{cssxref("inset-block")}} | `CSSPositionTryDescriptors.insetBlock` | `CSSPositionTryDescriptors["inset-block"]` |
| {{cssxref("inset-block-end")}} | `CSSPositionTryDescriptors.insetBlockEnd` | `CSSPositionTryDescriptors["inset-block-end"]` |
| {{cssxref("inset-block-start")}} | `CSSPositionTryDescriptors.insetBlockStart` | `CSSPositionTryDescriptors["inset-block-start"]` |
| {{cssxref("inset-inline")}} | `CSSPositionTryDescriptors.insetInline` | `CSSPositionTryDescriptors["inset-inline"]` |
| {{cssxref("inset-inline-end")}} | `CSSPositionTryDescriptors.insetInlineEnd` | `CSSPositionTryDescriptors["inset-inline-end"]` |
| {{cssxref("inset-inline-start")}} | `CSSPositionTryDescriptors.insetInlineStart` | `CSSPositionTryDescriptors["inset-inline-start"]` |
| {{cssxref("justify-self")}} | `CSSPositionTryDescriptors.justifySelf` | `CSSPositionTryDescriptors["justify-self"]` |
| {{cssxref("left")}} | `CSSPositionTryDescriptors.left` | `CSSPositionTryDescriptors["left"]` |
| {{cssxref("margin")}} | `CSSPositionTryDescriptors.margin` | `CSSPositionTryDescriptors["margin"]` |
| {{cssxref("margin-block")}} | `CSSPositionTryDescriptors.marginBlock` | `CSSPositionTryDescriptors["margin-block"]` |
| {{cssxref("margin-block-end")}} | `CSSPositionTryDescriptors.marginBlockEnd` | `CSSPositionTryDescriptors["margin-block-end"]` |
| {{cssxref("margin-block-start")}} | `CSSPositionTryDescriptors.marginBlockStart` | `CSSPositionTryDescriptors["margin-block-start"]` |
| {{cssxref("margin-bottom")}} | `CSSPositionTryDescriptors.marginBottom` | `CSSPositionTryDescriptors["margin-bottom"]` |
| {{cssxref("margin-inline")}} | `CSSPositionTryDescriptors.marginInline` | `CSSPositionTryDescriptors["margin-inline"]` |
| {{cssxref("margin-inline-end")}} | `CSSPositionTryDescriptors.marginInlineEnd` | `CSSPositionTryDescriptors["margin-inline-end"]` |
| {{cssxref("margin-inline-start")}} | `CSSPositionTryDescriptors.marginInlineStart` | `CSSPositionTryDescriptors["margin-inline-start"]` |
| {{cssxref("margin-left")}} | `CSSPositionTryDescriptors.marginLeft` | `CSSPositionTryDescriptors["margin-left"]` |
| {{cssxref("margin-right")}} | `CSSPositionTryDescriptors.marginRight` | `CSSPositionTryDescriptors["margin-right"]` |
| {{cssxref("margin-top")}} | `CSSPositionTryDescriptors.marginTop` | `CSSPositionTryDescriptors["margin-top"]` |
| {{cssxref("max-block-size")}} | `CSSPositionTryDescriptors.maxBlockSize` | `CSSPositionTryDescriptors["max-block-size"]` |
| {{cssxref("max-height")}} | `CSSPositionTryDescriptors.maxHeight` | `CSSPositionTryDescriptors["max-height"]` |
| {{cssxref("max-inline-size")}} | `CSSPositionTryDescriptors.maxInlineSize` | `CSSPositionTryDescriptors["max-inline-size"]` |
| {{cssxref("max-width")}} | `CSSPositionTryDescriptors.maxWidth` | `CSSPositionTryDescriptors["max-width"]` |
| {{cssxref("min-block-size")}} | `CSSPositionTryDescriptors.minBlockSize` | `CSSPositionTryDescriptors["min-block-size"]` |
| {{cssxref("min-height")}} | `CSSPositionTryDescriptors.minHeight` | `CSSPositionTryDescriptors["min-height"]` |
| {{cssxref("min-inline-size")}} | `CSSPositionTryDescriptors.minInlineSize` | `CSSPositionTryDescriptors["min-inline-size"]` |
| {{cssxref("min-width")}} | `CSSPositionTryDescriptors.minWidth` | `CSSPositionTryDescriptors["min-width"]` |
| {{cssxref("place-self")}} | `CSSPositionTryDescriptors.placeSelf` | `CSSPositionTryDescriptors["place-self"]` |
| {{cssxref("position-anchor")}} | `CSSPositionTryDescriptors.positionAnchor` | `CSSPositionTryDescriptors["position-anchor"]` |
| {{cssxref("right")}} | `CSSPositionTryDescriptors.right` | `CSSPositionTryDescriptors["right"]` |
| {{cssxref("top")}} | `CSSPositionTryDescriptors.top` | `CSSPositionTryDescriptors["top"]` |
| {{cssxref("width")}} | `CSSPositionTryDescriptors.width` | `CSSPositionTryDescriptors["width"]` |

## Instance methods

_No specific methods; inherits methods from its ancestor {{domxref("CSSStyleDeclaration")}}._

## Examples

The CSS includes a `@position-try` at-rule with a name of `--custom-right` and three descriptors.

```css
@position-try --custom-right {
inset-area: right;
width: 100px;
margin: 0 0 0 10px;
}
```

```js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption.style); // "[object CSSPositionTryDescriptors]"
console.log(tryOption.style.margin); // "0 0 0 10px"
console.log(tryOption.style["inset-area"]); // "right"
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i committed this line so i could read the page


## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{DOMxRef("CSSPositionTryRule")}}
- {{cssxref("@position-try")}}
- {{cssxref("position-try-options")}}
- [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) module
- [Using CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using)
- [Handling overflow: try options and conditional hiding](/en-US/docs/Web/CSS/CSS_anchor_positioning/Try_options_hiding)
66 changes: 66 additions & 0 deletions files/en-us/web/api/csspositiontryrule/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: CSSPositionTryRule
slug: Web/API/CSSPositionTryRule
page-type: web-api-interface
status:
- experimental
browser-compat: api.CSSPositionTryRule
---

{{APIRef("CSSOM")}}

The **`CSSPositionTryRule`** interface describes an object representing a {{cssxref("@position-try")}} [at-rule](/en-US/docs/Web/CSS/At-rule).

{{InheritanceDiagram}}

## Instance properties

_Inherits properties from its ancestor {{domxref("CSSRule")}}._

- {{domxref("CSSPositionTryRule.name")}} {{ReadOnlyInline}}
- : Represents the name of the position try option specified by the `@position-try` at-rule's {{cssxref("dashed-ident")}}.
- {{domxref("CSSPositionTryRule.style")}} {{ReadOnlyInline}}
- : Returns a {{domxref("CSSPositionTryDescriptors")}} object representing the declarations set in the body of the `@position-try` at-rule.

## Instance methods

_No specific methods; inherits methods from its ancestor {{domxref("CSSRule")}}._

## Examples

The CSS includes a `@position-try` at-rule with a name of `--custom-left` and three descriptors.

```css
@position-try --custom-left {
inset-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"
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{DOMxRef("CSSPositionTryDescriptors")}}
- {{cssxref("@position-try")}}
- {{cssxref("position-try-options")}}
- [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) module
- [Using CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using)
- [Handling overflow: try options and conditional hiding](/en-US/docs/Web/CSS/CSS_anchor_positioning/Try_options_hiding)
50 changes: 50 additions & 0 deletions files/en-us/web/api/csspositiontryrule/name/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "CSSPositionTryRule: name property"
short-title: name
slug: Web/API/CSSPositionTryRule/name
page-type: web-api-instance-property
browser-compat: api.CSSPositionTryRule.name
---

{{APIRef("CSSOM") }}

The **`name`** read-only property of the {{domxref("CSSPositionTryRule")}} interface represents the name of the position try option specified by the `@position-try` at-rule's {{cssxref("dashed-ident")}}.

## Value

A string.

## Examples

The CSS includes a `@position-try` at-rule with a name of `--custom-bottom` and three descriptors.

```css
@position-try --custom-bottom {
top: anchor(bottom);
min-width: 100px;
margin: 10px 0 0 0;
}
```

```js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption.name); // "--custom-bottom"
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{DOMxRef("CSSPositionTryDescriptors")}}
- {{cssxref("@position-try")}}
- {{cssxref("position-try-options")}}
- [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) module
- [Using CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using)
- [Handling overflow: try options and conditional hiding](/en-US/docs/Web/CSS/CSS_anchor_positioning/Try_options_hiding)
52 changes: 52 additions & 0 deletions files/en-us/web/api/csspositiontryrule/style/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: "CSSPositionTryRule: style property"
short-title: style
slug: Web/API/CSSPositionTryRule/style
page-type: web-api-instance-property
browser-compat: api.CSSPositionTryRule.style
---

{{ APIRef("CSSOM") }}

The **`style`** read-only property of the {{domxref("CSSPositionTryRule")}} interface returns a {{domxref("CSSPositionTryDescriptors")}} object representing the declarations set in the body of the `@position-try` at-rule.

## Value

A {{domxref("CSSPositionTryDescriptors")}} object.

## Examples

The CSS includes a `@position-try` at-rule with a name of `--custom-right` and three descriptors.

```css
@position-try --custom-bottom {
top: anchor(bottom);
min-width: 100px;
margin: 10px 0 0 0;
}
```

```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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add one that isn't declared to show what a value will look like when not set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea; done

console.log(tryOption.style.insetArea); // ""; no inset-area specified
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{DOMxRef("CSSPositionTryDescriptors")}}
- {{cssxref("@position-try")}}
- {{cssxref("position-try-options")}}
- [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) module
- [Using CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using)
- [Handling overflow: try options and conditional hiding](/en-US/docs/Web/CSS/CSS_anchor_positioning/Try_options_hiding)