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: Document CSS carousel functionality #38752

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

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented Mar 21, 2025

Description

Chrome 135 supports the new CSS carousel functionality — see the following ChromeStatus entries:

This PR aims to document all the new functionality. Specifically, it adds:

  • ::scroll-button() ref page
  • scroll-marker-group ref page
  • ::scroll-marker-group ref page
  • ::scroll-marker ref page
  • :target-current ref page
  • ::column ref page
  • A guide showing how to use the features together to create CSS carousels
  • All the above features to the CSS overflow module landing page
  • The pseudo-classes and pseudo-elements to the pseudo-classes and pseudo-elements landing pages

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner March 21, 2025 16:11
@chrisdavidmills chrisdavidmills requested review from estelle and removed request for a team March 21, 2025 16:11
@chrisdavidmills chrisdavidmills marked this pull request as draft March 21, 2025 16:11
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/l [PR only] 501-1000 LoC changed labels Mar 21, 2025
Copy link
Contributor

github-actions bot commented Mar 21, 2025

Preview URLs (10 pages)
Flaws (14)

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

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

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity

URL: /en-US/docs/Web/CSS/::scroll-button
Title: ::scroll-button()
Flaw count: 1

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity

URL: /en-US/docs/Web/CSS/::scroll-marker
Title: ::scroll-marker
Flaw count: 1

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity

URL: /en-US/docs/Web/CSS/::scroll-marker-group
Title: ::scroll-marker-group
Flaw count: 3

  • macros:
    • Macro produces link /en-US/docs/Web/CSS/interactive which is a redirect
    • Can't resolve /en-US/docs/Glossary/inert
    • Can't resolve /en-US/docs/Web/CSS/interactivity

URL: /en-US/docs/Web/CSS/:target-current
Title: :target-current
Flaw count: 1

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity

URL: /en-US/docs/Web/CSS/CSS_overflow/CSS_carousels
Title: Creating CSS carousels
Flaw count: 6

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity
    • Can't resolve /en-US/docs/Glossary/inert
    • Can't resolve /en-US/docs/Glossary/inert
    • Can't resolve /en-US/docs/Web/CSS/interactivity
    • Macro produces link /en-US/docs/Web/CSS/interactive which is a redirect
    • and 1 more flaws omitted

URL: /en-US/docs/Web/CSS/scroll-marker-group
Title: scroll-marker-group
Flaw count: 1

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/interactivity
External URLs (7)

URL: /en-US/docs/Web/CSS/::column
Title: ::column


URL: /en-US/docs/Web/CSS/::scroll-button
Title: ::scroll-button()


URL: /en-US/docs/Web/CSS/::scroll-marker
Title: ::scroll-marker


URL: /en-US/docs/Web/CSS/::scroll-marker-group
Title: ::scroll-marker-group


URL: /en-US/docs/Web/CSS/:target-current
Title: :target-current


URL: /en-US/docs/Web/CSS/CSS_overflow/CSS_carousels
Title: Creating CSS carousels


URL: /en-US/docs/Web/CSS/scroll-marker-group
Title: scroll-marker-group

(comment last updated: 2025-03-26 10:05:58)

@github-actions github-actions bot added size/xl [PR only] >1000 LoC changed and removed size/l [PR only] 501-1000 LoC changed labels Mar 24, 2025
@chrisdavidmills chrisdavidmills marked this pull request as ready for review March 24, 2025 15:40
@chrisdavidmills chrisdavidmills changed the title Document CSS carousel functionality Technical review: Document CSS carousel functionality Mar 24, 2025
Copy link
Contributor

@argyleink argyleink left a comment

Choose a reason for hiding this comment

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

excellent work as always!

left a few notes and some tips 🙂


A scroll container's **`::scroll-marker-group`** pseudo-element automatically contains any {{cssxref("::scroll-marker")}} pseudo-elements generated on its descendants. This allows them to be positioned and laid out as a group, and is typically used when creating a CSS carousel, to create a scroll position indicator. The individual scroll markers can also be used to navigate to their associated content items.

The {{cssxref("scroll-marker-group")}} property must be set to a non-`none` value on the scroll container for a `::scroll-marker-group` pseudo-element to be generated; the chosen value determines whether it is generated `before` or `after` the container's DOM content.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The {{cssxref("scroll-marker-group")}} property must be set to a non-`none` value on the scroll container for a `::scroll-marker-group` pseudo-element to be generated; the chosen value determines whether it is generated `before` or `after` the container's DOM content.
The {{cssxref("scroll-marker-group")}} property must be set to a non-`none` value on the scroll container for a `::scroll-marker-group` pseudo-element to be generated; the chosen value determines whether it is generated `before` or `after` the container's DOM content. A choice of `before` puts the marker group first in the carousel tab order, while `after` puts the markers at the end of the carousel tab order.

noting how this choice affects the focus order

Copy link
Contributor Author

@chrisdavidmills chrisdavidmills Mar 25, 2025

Choose a reason for hiding this comment

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

Ah, I didn't know this — useful, thanks!

I've added the following at the end of the paragraph:

It also affects where the scroll marker group appears in the container's tab order — before puts it at the start, while after puts it at the end.

Am I correct about the choice affecting where the pseudo-elements are generated? This is what the spec seems to be saying, although Chrome doesn't actually seem to do this (it always seems to put the generated pseudo-element before).

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've also added the information on tab order to the scroll-marker-group property page, and the CSS carousels guide.

Copy link
Contributor

Choose a reason for hiding this comment

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

i've got clarification, it affects both focus order and layout box order but not dom structure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, thanks for clarifying; I have updated the descriptions of the scroll-marker-group property value effects to suit.

Copy link
Contributor

@argyleink argyleink left a comment

Choose a reason for hiding this comment

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

lgtm

@chrisdavidmills chrisdavidmills changed the title Technical review: Document CSS carousel functionality Editorial review: Document CSS carousel functionality Mar 26, 2025
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.

i reviewed part of this PR.

We need the most basic possible example for the guide, and then we need to walk users through the enhancement from this is an scroll container that overflows to this is a basic carousel.

then we can add that basic example to each property page, then demonstrate updates to that feature only on each page, and link to the guide for the "to see how the rest of this demo worked".

a lot needs to be reworked, so pausing my review here. I'll try creating some codepens for you to help you out.


## See also

- {{cssxref("scroll-marker-group")}} and {{cssxref("interactivity")}} properties
Copy link
Member

Choose a reason for hiding this comment

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

broken link


{{CSSRef}}

The **`:target-current`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selects the {{cssxref("::scroll-marker")}} pseudo-element of a {{cssxref("scroll-marker-group")}} that is currently scrolled to, in other words, the **active** scroll marker. This can be used to style it differently, so the user can see see their navigation position inside the scroll marker group.
Copy link
Member

Choose a reason for hiding this comment

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

Suggest putting the word being defined before its definition.

Suggested change
The **`:target-current`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selects the {{cssxref("::scroll-marker")}} pseudo-element of a {{cssxref("scroll-marker-group")}} that is currently scrolled to, in other words, the **active** scroll marker. This can be used to style it differently, so the user can see see their navigation position inside the scroll marker group.
The **`:target-current`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selects the **active** scroll marker, the {{cssxref("::scroll-marker")}} pseudo-element of a {{cssxref("scroll-marker-group")}} that is currently scrolled to. This [selector](/en-US/docs/Web/CSS/CSS_selectors) can be used to style the active navigation position within a [scroll marker group]().

or possibly something like

 This [selector](/en-US/docs/Web/CSS/CSS_selectors) enables providing active styles to the current navigation position within a [scroll marker group](), which improves user experience.

Copy link
Member

Choose a reason for hiding this comment

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

if the selector is not valid on anything other than ::scroll-marker, we should say that (in case anyone thinks it might also be related to :target).


## Examples

See [Creating CSS carousels](/en-US/docs/Web/CSS/CSS_overflow/CSS_carousels) for full examples that use the `:target-current` pseudo-class.
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
See [Creating CSS carousels](/en-US/docs/Web/CSS/CSS_overflow/CSS_carousels) for full examples that use the `:target-current` pseudo-class.
See [Creating CSS carousels](/en-US/docs/Web/CSS/CSS_overflow/CSS_carousels#first_example) for examples of using the `:target-current` pseudo-class.

Comment on lines +27 to +29
::scroll-marker:target-current {
background-color: black;
}
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
::scroll-marker:target-current {
background-color: black;
}
::scroll-marker {
color: black;
background-color: white;
}
::scroll-marker:target-current {
color: white;
background-color: black;
}


## See also

- {{cssxref("scroll-marker-group")}} and {{cssxref("interactivity")}} properties
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
- {{cssxref("scroll-marker-group")}} and {{cssxref("interactivity")}} properties
- {{cssxref("scroll-marker-group")}}
- {{cssxref("theOtherThing")}}


## First example layout with flexbox

In the first example, the unordered list is given a {{cssxref("width")}} of `100vw` to force it to the full width of the viewport, a {{cssxref("height")}} of `300px`, and `20px` of {{cssxref("padding")}}. We then give it a {{cssxref("display")}} value of `flex` to force the child list items to display horizontally, and a {{cssxref("gap")}} of `4vw` between each one.
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 first example, the unordered list is given a {{cssxref("width")}} of `100vw` to force it to the full width of the viewport, a {{cssxref("height")}} of `300px`, and `20px` of {{cssxref("padding")}}. We then give it a {{cssxref("display")}} value of `flex` to force the child list items to display horizontally, and a {{cssxref("gap")}} of `4vw` between each one.
The unordered list is made to fill the full width of the viewport, with a {{cssxref("height")}} of `300px` and some {{cssxref("padding")}}. We set the {{cssxref("display")}} to`flex`, defaulting the {{cssxref("flex-direction")}} `row` and the {{cssxref("flex-wrap")}} to `no-wrap`, and add a {{cssxref("gap")}} between each item. As the viewport is wider than our now horizontal row of flex-items, the `<ul>` will be a {{glossary("scroll container")}}.

Stop this section at this point, and show the demo, and suggest they scroll left and right,. We conclude "flex layout" before movin on.

border: 1px solid #ddd;
padding: 20px;

flex: 0 0 calc(100vw - 40px);
Copy link
Member

Choose a reason for hiding this comment

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

needlessly complex. does 100% work? or 96vw which is the width minus the gap?

Comment on lines +130 to +133
list-style-type: none;
background-color: #eee;
border: 1px solid #ddd;
padding: 20px;
Copy link
Member

Choose a reason for hiding this comment

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

move the basic stuff to the first section. and the flex to the flexlayout section.

is the snap necessary? If yes, explain what it does, how it works, and demo it with guidance to test it out here and links to learn more.
if it's not necessary for carousels, add it after the carousel works in a rudimentary way as an enhancement.
either way, scroll snapping should be under it's own subheader with no other features explained in that part.

}
```

## Setting inertness on non-visible articles
Copy link
Member

Choose a reason for hiding this comment

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

remove this section.
inertness is not ready yet. The links are broken. And, this is an advanced topic that should come after the carouself is otherwise working.

Copy link
Member

Choose a reason for hiding this comment

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

this section is NOT reviewed.

```

## Creating the scroll buttons

Copy link
Member

@estelle estelle Mar 27, 2025

Choose a reason for hiding this comment

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

we need to explain why we are doing this and progress this guide in an order that teaches the features by enhancing the demo step by step. Add someone like "What we have now is a horizontal row of items, made up of individual flex items, with only one item visible at a time. We have to scroll to see the next item . The features defined in the ...." here, then go on.

I think it makes more sense to start with group and markers before left and right. but maybe there's a reason to go in this order.

@estelle
Copy link
Member

estelle commented Mar 28, 2025

I am working on a codepen for you. see https://codepen.io/estelle/pen/ByaOveM. it contains the steps to add in the order to add them for the guide to progress in a way that will make sense to people learning these features for the first time.

Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Mar 28, 2025
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 merge conflicts 🚧 [PR only] size/xl [PR only] >1000 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants