Re: [csswg-drafts] [css-grid] grid-gap is still taking up space when an element defined in grid-template-area is not on the page. (#5813)

> In this thread I just see references to collapsing gaps, but the current spec only has this concept for the gutters of a collapsed track.
> 
> It's not clear to me what this proposal would do if the track is defined to be e.g. `100px`. I don't think it makes much sense to collapse gaps if the track won't end up being zero.

I agree. That's what I meant when I wrote "have a way to control whether to collapse gaps adjacent to empty grid tracks" but that wording was obviously ambiguous.

> But I think it would be simpler to reuse the existing concept, and instead of adding a feature to only collapse gutters, add a feature to collapse empty tracks (and the adjacent gutters will collapse too).
> 
> Like `empty-tracks: collapse | auto`, where `collapse` (or maybe `hide` to align with `empty-cells`?) would collapse all empty tracks, and `auto` would only collapse the empty tracks generated by an `auto-fit` repetition.

That probably covers a lot of use cases. Though I also have [an example](https://www.gamestar.de) in which this wouldn't work:

![Use case for grid gap collapsing without track collapsing](https://github.com/w3c/csswg-drafts/assets/958943/95dd894a-183f-479a-9999-387d4416c0ea)

In that widget, the image on the left spans across all grid rows, so they are not empty. The contents on the right are placed in individual grid cells. The rows are defined as `1fr repeat(4, min-content) 1fr`. So one of the cells on the right is not filled. This gets obvious when a `row-gap` is added:

![Same screenshot as above but with `row-gap` applied to show the empty cell](https://github.com/w3c/csswg-drafts/assets/958943/38589103-e14c-45ea-89da-b3ca51624270)

In this case, it would make sense to collapse the adjacent gaps plus the 0-width track to always keep the contents on the right vertically centered.

So the two cases, empty and 0-width should be controllable. Not sure whether they should be handled individually or together. Though I agree that this new feature should affect collapsing both tracks and gutters.

Sebastian

-- 
GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5813#issuecomment-1679724048 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 15 August 2023 22:44:23 UTC