-
Notifications
You must be signed in to change notification settings - Fork 657
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] Ability to clamp track spanning #5852
Comments
It seems to me like this should be solvable, and would be very useful. Here's my proposal (actual function name TBD):
|
Agenda+ to see if we can move this forward |
Would |
I was expecting we would have to limit this to the explicit grid - primarily for use with |
<div style="display: grid; grid-template-columns: repeat(4, auto)">
<div style="grid-column: span(1, 3)"></div>
<div style="grid-column: span 1"></div>
</div> If we place the 1st item with a span of 1, then the 2nd item is placed in column 2, so we won't be able to make the 1st item span more tracks without overlapping. But since there are 4 columns, I suspect authors would prefer the 1st item to take 3 columns, and place the 2nd item in the 4th column. But this may increase the complexity. |
About the syntax, even though Also, the current syntax is |
In my proposal, placement would be based on the max (clamped by the available columns). So in this case, the first div would span 3. |
The CSS Working Group just discussed The full IRC log of that discussion<TabAtkins> miriam: especially ins ituation where you use auto-fit/fill repeating grid, there's a pain point where you want element to span multiple columns *if avaialble*, but not add new columns if they're not needed<TabAtkins> miriam: This is a problem with auto grids, you have to reach for MQ/CQ, figure out the breakpoints, and use that to change the span size <jensimmons> YYEEEESSSSS This is such a pain to do manually. <TabAtkins> miriam: There's been many requests for this, been chatting with Elika, wanted to push a proposal for fixing this <TabAtkins> miriam: Suggest a `span(min, max)` function <TabAtkins> miriam: so `span(1, 3)` - for the sake of determining what columns are *needed* we use the min, and for the sake of placement we use the max <TabAtkins> miriam: happy to bikeshed the specifics, but wanted to know if we can start working on it <TabAtkins> fantasai: in favor generally, i think the syntax is reasoanble <dbaron> s/placement we use the max/placement we use the max. Could maybe also be an `all` value./ <TabAtkins> fantasai: currently span is a keyword, this would shift it to a function, we could maybe make the second argument optional <rachelandrew> +1 in general, again something people really would like to do <TabAtkins> fantasai: one naming concern is that "all" would span only the explicit tracks, not the implicit <iank_> this adds a bunch of complexity with mansonry, and they willl span a variable amount of columns <TabAtkins> ???: so in order to determine implicit gridlines you'll use the min span <TabAtkins> ???: but for placement you use the max - how does that work? <TabAtkins> miriam: You'd use max, clamped by the number of columns avaiable. <fantasai> s/???/Ethan/ <fantasai> s/???/Ethan/ <oriol> q+ <TabAtkins> iank_: With the current masonry spec, this makes it... when you place masonry items, they can span variable # of tracks for sizing, that's a somewhat complex interaction <TabAtkins> fantasai: I think for sizing they'd span the min <TabAtkins> miriam: I'd also assume that <TabAtkins> iank_: I don't know if that's correct <TabAtkins> fantasai: It's a bit awkward for masonry in general. even if you're doing placement, because of the way masonry works you want to palce it into the shortest column, but then you won't bea ble to span anyway <TabAtkins> fantasai: Some cases where you can, but it's rare - you need similar-height items lining up in rows, and then you probably dont' need masonry anyway <TabAtkins> iank_: Yeah, for final palcement. But for track sizing, if you're running "place everywhere in ever position", you can have something that'll span 10, then 9, then 8, etc <TabAtkins> fantasai: That's why when you're calculating sizes, assume it's spanning the min <TabAtkins> fantasai: Since it'll usually not span more than that <TabAtkins> Rossen__: we're out of time, let's continue discussing in the issue |
I was in the queue to point out that apparently this is not just placing the min, and then growing up to the max after placement, as per #5852 (comment). Also to state what I mentioned in #5852 (comment) |
I'd be happy with a keyword approach rather than a function. I don't have strong opinions on syntax at this point. I would expect the max span value, as constrained by the total grid tracks available, to take priority in placement. The goal of this feature is not to 'fill the remaining tracks' after placement (I think there's another issue for that) but to span the max tracks without generating additional tracks. |
Currently, if any element spans multiple columns when using
auto-fill
, the grid is incapable of gracefully handling sizing below that amount of columns. The extra columns get squished, as demonstrated in the following example:Using a syntax like
span-minmax(1, 3)
to clamp the spanning (as proposed by @MatsPalmgren here) would allow the grid to be fully responsive.One such use case mentioned on that issue is:
The text was updated successfully, but these errors were encountered: