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

[css-grid] Collapsed grid tracks and content distribution #1140

Closed
SelenIT opened this issue Mar 29, 2017 · 7 comments
Closed

[css-grid] Collapsed grid tracks and content distribution #1140

SelenIT opened this issue Mar 29, 2017 · 7 comments
Labels
Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-align-3 Current Work css-grid-1 Tracked in DoC

Comments

@SelenIT
Copy link
Collaborator

SelenIT commented Mar 29, 2017

According to the CSS Grid spec, the grid tracks that collapse because of auto-fit repetition, have zero width and the gutters between them also collapse:

When a collapsed track’s gutters collapse, they coincide exactly—the two gutters overlap so that their start and end edges coincide. If one side of a collapsed track does not have a gutter (e.g. if it is the first or last track of the implicit grid), then collapsing its gutters results in no gutter on either “side” of the collapsed track.

The question is, how these collapsed tracks and gutters should be treated for the justify-/align-content purposes? On the one hand, the collapsed tracks are still technically separate tracks, so they may be distributed as usually (which we currently see in Blink/WebKit implementation). On the other hand, "the exact coincidence" of the collapsed grid gutters, one of which is the last track gutter, seems to imply that there would be effectively no gutter after the last non-empty track, so no extra space to distribute, and the non-empty tracks should be distributed as if the collapsed tracks didn't exist at all. This is what currently the Gecko implementation does.

The difference in the two implementations behavior can be seen in this example (provided by @mrego): http://jsbin.com/rosarub/edit?html,css,output

Personally, I believe that the Firefox's behavior (ignoring the collapsed tracks completely) makes more sense from the practical perspective. Having invisible things that affect distribution of the visible content is confusing and sometimes even annoying, the same way as wrapping abspos children of the flex container in anonymous flex items was. I supposed that that the whole point of collapsing tracks is making them not affecting the layout at all. But it's just my opinion.

Should the spec be clarified for this aspect?

@javifernandez
Copy link
Contributor

I agree this should be clarified in the CSS Box Alignment specification:

https://drafts.csswg.org/css-align-3/#distribution-grid

Alignment Subject(s) The grid tracks in the appropriate axis.

Perhaps it should specify whether those tracks can be or not collapsed tracks.

@rachelandrew
Copy link
Contributor

I think as an author I prefer the Gecko version - although I can see the logic of both. However if I am distributing space I probably want it distributed between the things I can currently see.

@fantasai
Copy link
Collaborator

Yeah, the collapsed tracks should be essentially invisible, as they are when gaps are added. Content distribution effectively increases the gaps, and if we later add the ability to style gaps (e.g. by adding column/row rules), then that will be noticeable.

fantasai added a commit that referenced this issue Mar 30, 2017
@tabatkins
Copy link
Member

@javifernandez Note that Chrome's implementation is actually wrong for a different reason - if you put i2 into the fourth column (so it's columns 2 and 3 that collapse), Chrome's rendering puts a lot of extra space in the middle, indicating that each of the gutters there are getting the extra space and independently laying out. The spec requires that the gutters coincide, tho, so it should look exactly like your current example, with the tracks shifted to the left side.

But yeah, Firefox's rendering is intended, and we're clarifying now.

@fantasai
Copy link
Collaborator

Well, we technically didn't specify that the space is part of the gutter, either, so they can't have been wrong for that reason just yet. But now they are! All clarified! Thanks for the report!

@tabatkins
Copy link
Member

Man, where's that space gonna even go if the gutters coincide, tho? Even if you put it to one side of the gutter (rather than expanding the gutter), the gutters are on top of each other!

@SelenIT
Copy link
Collaborator Author

SelenIT commented Mar 30, 2017

Thanks a lot for clarifying the specs!

@fantasai fantasai added the Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. label May 2, 2017
@fantasai fantasai added this to the css-grid-1 CR 2016-09-29+ milestone Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-align-3 Current Work css-grid-1 Tracked in DoC
Projects
None yet
Development

No branches or pull requests

5 participants