Skip to content

[css-scroll-snap] Do scroll-margin-* properties accept percentages? #3289

Closed

Description

@ewilligers

Should the value accept percentages, or should the computed value exclude percentages?

https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-top

Name: scroll-margin-top, scroll-margin-right, scroll-margin-bottom, scroll-margin-left
Value: <length>
Percentages: n/a
Computed value: a computed <length-percentage> value

https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-block-start

Name: scroll-margin-block-start, scroll-margin-inline-start, scroll-margin-block-end, scroll-margin-inline-end
Value: <length>
Percentages: n/a
Computed value: a computed <length-percentage> value

https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin

Name: scroll-margin
Value: <length>{1,4}
Percentages: n/a
Computed value: per side, a computed <length-percentage> value

Activity

  1. jonjohnjohnson commented on Nov 6, 2018

    @jonjohnjohnson

    Well scroll-padding allows <length-percentage>, so I would hope scroll-margin could similarly allow for percentages to resolve against the "corresponding dimension of the [associated] scroll container’s scrollport"?

    https://drafts.csswg.org/css-scroll-snap-1/#scroll-padding

  2. fantasai commented on Nov 14, 2018

    @fantasai
    Collaborator

    Looks like an error during the Computed Value line updates. I'll fix it.

  3. jonjohnjohnson commented on Nov 15, 2018

    @jonjohnjohnson

    @fantasai So am I correct in thinking a snapport with height of 200px would allow a child element to snap 50px off the top edge when using scroll-snap-align: start & scroll-margin-block-start: 25%?

  4. fantasai commented on Jan 2, 2019

    @fantasai
    Collaborator

    @jonjohnjohnson Ah, no, scroll-margin doesn't accept percentages. If you look, the fix was to remove the stray mention of them from the Computed Value line. It was explicitly decided not to include them on 'scroll-margin' because, unlike for scroll-padding which is specified on the scroll container, it wasn't clear what the percentage should be relative to: the scrollport? the element's own size? it's containing block width? something else? So we left percentages out of the scroll-margin value space until/unless it becomes clear what they most need to do.

  5. jonjohnjohnson commented on Apr 1, 2019

    @jonjohnjohnson

    @fantasai IMHO I think the group should give another look at scroll-margin accepting percentages as relative to the scrollport, since we also have percentage values in box offsets/insets for a sticky position scheme being relative to the scrollport. I've been playing around with mixing sticky and snap features, wishing they jived better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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