You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-scroll-snap] Do scroll-margin-* properties accept percentages? #3289
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"?
@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%?
@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.
@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.
Activity
jonjohnjohnson commentedon Nov 6, 2018
Well
scroll-paddingallows<length-percentage>, so I would hopescroll-margincould 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
fantasai commentedon Nov 14, 2018
Looks like an error during the Computed Value line updates. I'll fix it.
[css-scroll-snap-1] Fix computed value lines of scroll-margin to not …
jonjohnjohnson commentedon Nov 15, 2018
@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%?fantasai commentedon Jan 2, 2019
@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.
jonjohnjohnson commentedon Apr 1, 2019
@fantasai IMHO I think the group should give another look at
scroll-marginaccepting 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.