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

Add scroll-markers feature #2654

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/scroll-markers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: Scroll markers
description: The `::scroll-marker` CSS pseudo-element is a focusable control within its ancestor scroll container's `::scroll-marker-group` that scrolls to its originating element.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm having trouble understanding this. Would you mind giving me a practical example of how this might work/what this would look like? This would help me understand, and potentially propose a slight rewrite of this.

Copy link
Author

Choose a reason for hiding this comment

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

If you have chrome canary with experimental web platform features enabled, there are some great demos at:

As an example, the following creates a set of circular "markers" to scroll to each of the slides in a slideshow:

<style>
  .slides {
    overflow: auto;
    scroll-snap-type: x mandatory;
    white-space: nowrap;
    scroll-marker-group: after;
    counter-reset: slide-number;
  }
  .slide::scroll-marker {
    counter-increment: slide-number;
    content: counter(slide-number);
    border-radius: 50%;
    border: 1px solid black;
  }
}
</style>
<div class=slides>
  <div class=slide></div>
  <div class=slide></div>
  <div class=slide></div>
  <div class=slide></div>
  <div class=slide></div>
<div class=slideshow>

Here's a somewhat simple codepen trying to show the same: https://codepen.io/flackr/pen/MWMLPpP

spec: https://drafts.csswg.org/css-overflow-5/#scroll-markers
group: scrolling