Skip to content

[css-overflow] Proposing scroll-start: allowing overflow scroll to not always start at 0 on 1st layout pass #6986

@argyleink

Description

@argyleink

📄 Explainer

Currently, JavaScript needs to show up at "never the right time" to adjust a scroll position to a specific starting place. This CSS property proposal seeks to remedy page load scroll jank by allow specifying a scroll-start position with a specific or by giving a child element scroll-start-target: auto at which point an absolute length is derived from the element and the scroll direction.


Example: set the start position to an absolute value:

:root { --nav-height: 100px }

.snap-scroll-y {
  scroll-start-y: var(--nav-height);
}

Example: set the start position to a snap child

.snap-scroll-inline {
  overflow-inline: scroll;
  scroll-snap-type: inline mandatory;
}

.snap-scroll-inline > #snap-start {
  scroll-start-target-inline: auto;
}

There's a lot more use cases and details (like interaction with fragment navigation) about the proposal in the Explainer

Would love to present the details of the explainer to the CSSWG for feedback 🙂

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions