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 3: sizing and positioning part 1 #33493

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented May 8, 2024

Description

CSS Anchor Positioning is set to be released in Chrome 125 (see the associated Chrome Status entry).

This PR (part of a series; see the first PR here) adds the following content:

  • The anchor() function
  • Properties that support anchor() as a value:
    • top
    • left
    • bottom
    • right
    • inset-block-start
    • inset-block-end
    • inset-inline-start
    • inset-inline-end
    • inset-block
    • inset-inline
    • inset
  • The anchor-center value, which is supported on the following properties:
    • justify-self
    • align-self
    • justify-items
    • align-items
    • place-items
    • place-self

Do not merge until #33058 is merged.

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner May 8, 2024 14:31
@chrisdavidmills chrisdavidmills requested review from bsmth and removed request for a team May 8, 2024 14:31
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/m 51-500 LoC changed labels May 8, 2024
Copy link
Contributor

github-actions bot commented May 8, 2024

Preview URLs (19 pages)
Flaws (22)

Note! 12 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/CSS/anchor
Title: anchor()
Flaw count: 9

  • macros:
    • /en-US/docs/Web/CSS/anchor-name does not exist
    • /en-US/docs/Web/CSS/position-anchor does not exist
    • /en-US/docs/Web/CSS/position-anchor does not exist
    • /en-US/docs/Web/CSS/anchor-name does not exist
  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using
    • Can't resolve /en-US/docs/Web/HTML/Global_attributes/anchor
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using

URL: /en-US/docs/Web/CSS/CSS_Functions
Title: CSS value functions
Flaw count: 8

  • macros:
    • /en-US/docs/Web/CSS/path redirects to /en-US/docs/Web/CSS/basic-shape/path
    • /en-US/docs/Web/CSS/animation-timeline/anchor does not exist
    • /en-US/docs/Web/CSS/animation-timeline/anchor-size does not exist
    • /en-US/docs/Web/CSS/animation-timeline/inset-area_function does not exist
    • /en-US/docs/Web/CSS/position-try-options does not exist
    • and 1 more flaws omitted
  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using

URL: /en-US/docs/Web/CSS/justify-self
Title: justify-self
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center

URL: /en-US/docs/Web/CSS/align-self
Title: align-self
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center

URL: /en-US/docs/Web/CSS/place-self
Title: place-self
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center

URL: /en-US/docs/Web/CSS/justify-items
Title: justify-items
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center

URL: /en-US/docs/Web/CSS/align-items
Title: align-items
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center

(comment last updated: 2024-05-31 14:25:51)

@chrisdavidmills chrisdavidmills changed the title Add anchor() function ref page Tech review: CSS anchor positioning 3: sizing and positioning May 8, 2024
@chrisdavidmills chrisdavidmills marked this pull request as draft May 8, 2024 14:46
@chrisdavidmills chrisdavidmills changed the title Tech review: CSS anchor positioning 3: sizing and positioning Tech review: CSS anchor positioning 3: sizing and positioning part 1 May 9, 2024
@chrisdavidmills chrisdavidmills marked this pull request as ready for review May 9, 2024 10:47
Copy link

@mfreed7 mfreed7 left a comment

Choose a reason for hiding this comment

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

Looks good! Lots of comments, but overall very nice.

files/en-us/web/css/align-items/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/align-self/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/anchor/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/anchor/index.md Show resolved Hide resolved
files/en-us/web/css/inset-block/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/inset-inline/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/left/index.md Show resolved Hide resolved
@bsmth bsmth removed their request for review May 13, 2024 11:58
@chrisdavidmills chrisdavidmills changed the title Tech review: CSS anchor positioning 3: sizing and positioning part 1 Editorial review: CSS anchor positioning 3: sizing and positioning part 1 May 20, 2024
@chrisdavidmills chrisdavidmills requested review from estelle and removed request for mfreed7 May 20, 2024 18:01
@chrisdavidmills
Copy link
Contributor Author

Thanks for the tech review, @mfreed7.

@estelle, this one is ready for editorial review too.

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

Partial review. Done reviewing for today.

@@ -22,6 +22,7 @@ align-items: stretch;

/* Positional alignment */
/* align-items does not take left and right values */
align-items: anchor-center; /* Center items with respect to an associated anchor element */
Copy link
Member

Choose a reason for hiding this comment

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

remove all occurrences of new comments in syntax.

Suggested change
align-items: anchor-center; /* Center items with respect to an associated anchor element */
align-items: anchor-center;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, for all the -items and -self properties

@@ -79,6 +80,8 @@ align-items: unset;
- : Used alongside an alignment keyword. If the chosen keyword means that the item overflows the alignment container causing data loss, the item is instead aligned as if the alignment mode were `start`.
- `unsafe`
- : Used alongside an alignment keyword. Regardless of the relative sizes of the item and alignment container and whether overflow which causes data loss might happen, the given alignment value is honored.
- `anchor-center` {{experimental_inline}}
- : In the case of **anchor-positioned** elements (see [CSS Anchor Positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning)), the `anchor-center` value is used to align the items to the center of the associated anchor element in the block direction.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- : In the case of **anchor-positioned** elements (see [CSS Anchor Positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning)), the `anchor-center` value is used to align the items to the center of the associated anchor element in the block direction.
- : In the case of **anchor-positioned** elements (see [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/USING/ANCHOR CENTER)), aligns the items to the center of the associated anchor element in the block direction.
  • Change the case of links to all articles / blogs / modules / guides / etc. to sentence case
  • when possible, link to relevant section
  • don't repeat value name in value description unless necessary: just define the value succinctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, done, and done

files/en-us/web/css/anchor/index.md Show resolved Hide resolved

{{CSSRef}}

The **`anchor()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) can be used as a value for an **anchor-positioned** element's [inset properties](#properties_that_accept_anchor_function_values), to position it relative to the edges of its associated **anchor element**.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The **`anchor()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) can be used as a value for an **anchor-positioned** element's [inset properties](#properties_that_accept_anchor_function_values), to position it relative to the edges of its associated **anchor element**.
The **`anchor()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) is used as a value for [inset properties](#properties_that_accept_anchor_function_values) on elements that are absolutely positioned. The {{cssxref("length")}} value returned positions the element that distance, in the direction of the inset property, relative to the edges of its associated **anchor element** or the XXX if the element is not tethered to an anchor element.

My feedback in made in the form of a suggestion, but is not a suggestion. These are the topics that need to be covered in this summary sentence / paragraph. But my mind is fuzzy, so the suggestion is not well written..

  • we need to create an inset properties page
  • if used on an absolute / fixed element that doesn't have an anchor, what is the effect?
  • The inset properties section below - i edited that section in a different PR. Apply that edit here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is a bit overkill to try to explain all this upfront in the first paragraph. It is all explained further down the page, and I'd prefer to make the opening paragraph a concise description of the property's function.

I've added a description of what happens if there is no anchor element associated with the positioned element to the Description section.

I've also updated the list of inset properties to be presented in the same way as in the guide page you looked at previously.

The specification also defines `inside` and `outside` values, which are currently not supported by any browser.

- {{cssxref("length-percentage")}} {{optional_inline}}
- : This is a fallback value that specifies what the function should return if the `anchor()` function is invalid.
Copy link
Member

Choose a reason for hiding this comment

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

if something is invalid, it's ignored. i fixed this on another page, but right now i can't remember the verbiage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found it:

Specifies a fallback value the function should resolve to if the anchor() function would otherwise be invalid.

I'll use the same wording form for anchor-size() too

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

reviewed

@@ -22,6 +22,7 @@ align-items: stretch;

/* Positional alignment */
/* align-items does not take left and right values */
align-items: anchor-center;
Copy link
Member

Choose a reason for hiding this comment

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

make this last within this first group as, of these values, for this property, it is the least supported, and right now would be the least used option.

@@ -79,6 +80,8 @@ align-items: unset;
- : Used alongside an alignment keyword. If the chosen keyword means that the item overflows the alignment container causing data loss, the item is instead aligned as if the alignment mode were `start`.
- `unsafe`
- : Used alongside an alignment keyword. Regardless of the relative sizes of the item and alignment container and whether overflow which causes data loss might happen, the given alignment value is honored.
- `anchor-center` {{experimental_inline}}
Copy link
Member

Choose a reason for hiding this comment

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

put before safe if safe anchor-center is a valid value

@@ -79,6 +80,8 @@ align-items: unset;
- : Used alongside an alignment keyword. If the chosen keyword means that the item overflows the alignment container causing data loss, the item is instead aligned as if the alignment mode were `start`.
- `unsafe`
- : Used alongside an alignment keyword. Regardless of the relative sizes of the item and alignment container and whether overflow which causes data loss might happen, the given alignment value is honored.
- `anchor-center` {{experimental_inline}}
- : In the case of **anchor-positioned** elements (see [Centering on the anchor using `anchor-center`](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center)), aligns the items to the center of the associated anchor element in the block direction.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- : In the case of **anchor-positioned** elements (see [Centering on the anchor using `anchor-center`](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center)), aligns the items to the center of the associated anchor element in the block direction.
- : In the case of [**anchor-positioned**](link to module) elements, aligns the items to the center of the associated anchor element in the block direction. See [Centering on the anchor using `anchor-center`](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using#centering_on_the_anchor_using_anchor-center).

@@ -22,6 +22,7 @@ align-items: stretch;

Copy link
Member

Choose a reason for hiding this comment

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

reviews for this page apply to align, place and justify pages.

Comment on lines +44 to +55
- : Specifies the side of the anchor element that the side of the positioned element denoted by the inset property will be positioned relative to. This can be expressed using the following values:

- Physical values:
- `top`: The top of the anchor element.
- `right`: The right of the anchor element.
- `bottom`: The bottom of the anchor element.
- `left`: The left of the anchor element
- Logical values:
- `start`: The logical start of the anchor element's block axis.
- `end`: The logical end of the anchor element's block axis.
- `self-start`: The logical start of the anchor element's inline axis.
- `self-end`: The logical end of the anchor element's inline axis.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- : Specifies the side of the anchor element that the side of the positioned element denoted by the inset property will be positioned relative to. This can be expressed using the following values:
- Physical values:
- `top`: The top of the anchor element.
- `right`: The right of the anchor element.
- `bottom`: The bottom of the anchor element.
- `left`: The left of the anchor element
- Logical values:
- `start`: The logical start of the anchor element's block axis.
- `end`: The logical end of the anchor element's block axis.
- `self-start`: The logical start of the anchor element's inline axis.
- `self-end`: The logical end of the anchor element's inline axis.
- : Specifies the side of the anchor element that the side of the positioned element denoted by the inset property will be positioned relative to. Valid values include:
- `top`: The top of the anchor element.
- `right`: The right of the anchor element.
- `bottom`: The bottom of the anchor element.
- `left`: The left of the anchor element
- `start`: The logical start of the anchor element's block axis.
- `end`: The logical end of the anchor element's block axis.
- `self-start`: The logical start of the anchor element's inline axis.
- `self-end`: The logical end of the anchor element's inline axis.
- `center`: The center of the axis of the inset property on which the `anchor()` function is set.
- {{cssxref("percentage")}}: Specifies the distance, as a percentage, from the start of the axis of the inset property on which the `anchor()` function is set.
For {{glossary("physical properties", "physical")}}, inset values, any physical anchor side value uses has to be along the same axis as the inset value being set.

preferably as a DL

Copy link
Member

Choose a reason for hiding this comment

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

move everything else to description

```css
/* property: anchor(anchor-side) */
top: anchor(bottom);
inset-block-end: anchor(start);
Copy link
Member

Choose a reason for hiding this comment

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

add a % value.
Also used anchor in a calc fuctnion.

@@ -59,6 +63,10 @@ bottom: unset;
- for _absolutely positioned elements_, the position of the element is based on the {{Cssxref("top")}} property, while `height: auto` is treated as a height based on the content; or if `top` is also `auto`, the element is positioned where it should vertically be positioned if it were a static element.
- for _relatively positioned elements_, the distance of the element from its normal position is based on the {{Cssxref("top")}} property; or if `top` is also `auto`, the element is not moved vertically at all.

- {{cssxref("anchor()")}} {{experimental_inline}}

- : Resolves to a {{cssxref("<length>")}} value relative to the position of the top and/or bottom edges of an absolutely- or fixed-positioned element's associated **anchor element**.
Copy link
Member

Choose a reason for hiding this comment

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

link anchor element

@@ -329,6 +329,17 @@ The following functions are used as a value of different `animation-timeline` pr
- {{cssxref("animation-timeline/view", "view()")}}
- : Sets the {{cssxref("animation-timeline")}} of an element to an _anonymous view progress timeline_.

## Anchor positioning functions

The following functions are used when positioning and sizing **anchor-positioned elements** relative to the location and size of their associated **anchor elements**, and defining **position try options**. For more details and usage information, see the [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) module landing page and the [Using CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning/Using) guide.
Copy link
Member

Choose a reason for hiding this comment

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

put the "for more info" after the functions.

@@ -44,6 +48,8 @@ inset-block: unset;

The `inset-block` property takes the same values as the {{cssxref("left")}} property.

Note that setting the same {{cssxref("anchor()")}} value for both constituent properties (for example, `inset-block: anchor(start)`) may produce strange or unexpected results, as the values will both be relative to a single line on an anchor element (e.g. one of its sides) rather than two separate sides of the viewport or a containing block.
Copy link
Member

Choose a reason for hiding this comment

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

this is kind of "out of the blue" here, and doesn't make sense as a stand alone.

@@ -44,6 +48,8 @@ inset-inline: unset;

The `inset-inline` property takes the same values as the {{cssxref("left")}} property.

Note that setting the same {{cssxref("anchor()")}} value for both constituent properties (for example, `inset-inline: anchor(start)`) may produce strange or unexpected results, as the values will both be relative to a single line on an anchor element (e.g. one of its sides) rather than two separate sides of the viewport or a containing block.
Copy link
Member

Choose a reason for hiding this comment

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

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/m 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants