Open fantasai opened 7 years ago
maxmin ?
grid-template-columns: 1fr repeat(4, maxmin(250px, 20%)) 1fr;
between()
?
I like the idea of maxmin()
. It's clear that it is essentially the same functionality as minmax()
but the syntax itself suggests that it has different priorities :)
It would have to be max value first, min value second to make sense though.
If I understood this correctly, the feedback is that sizing properties allows both width: 20%; max-width: 250px
and min-width: 20%; max-width: 250px
, but that grid only allows the latter with minmax
. Is that correct?
If that's correct I'd say prefmax(20%, 250px)
but I think the notion of preferred
width has been retired in specs, and I can't remember what is the new name for this.
How about adding a new parameter? Just like minmax(min-value, max-value, more-prior-item)
The third param more-prior-item
specifies which one has the priority.
eg. minmax(20%, 250px, 'min')
is equal to minmax(20%, 250px)
eg. minmax(20%, 250px, 'max')
makes max wins over min, which could solve the maxwidth situation.
Otherwise I'll have to make do with using a pixel minimum, which will means my fr margins will take up no space at smaller viewports, so i'll have to add tedious media queries.
I think, no space at smaller viewports, it's an independent situation from minmax()
.
Maybe it should be solved by grid layout, adding rules to limit the minwidth of the remaining space or something like that?
The Working Group just discussed Allow minmax where max wins over min
, and agreed to the following:
RESOLVED: add a feature that allows max to win over min in Grid L2, name tbd
So my preference is to go with an optional trailing keyword dictating the behavior. clamp()
(#2519) probably wants the same thing, and a keyword is definitely the way to go there (particularly since clamp() also wants a third behavior - swapping the min/max when they're in the wrong order; you can't do that with Grid tho, if either of the sizes are content-based).
So maybe something like:
minmax(<min>, <max>, [min-wins | max-wins]?)
Alternate name pairs: prefer-min | prefer-max
I prefer the first set [min-wins | max-wins]
, way more straightforward.
I like the keyword idea too, could it be just min
or max
as keywords?
It doesn't seem immediately clear what min-max(20%, 250px, max)
means. The *-wins
keywords are suggestive - "win" implies it affects how some conflict is resolved, and the only time there can be a conflict is if the min and max are misordered.
I'm fine with the proposal, I'd just note that for non-grid things, we have [min-width, width, max-width]
.
Adding a min-wins
keyboard that toggles the first argument of minmax
between min-width
and width
is nice, but it means you still can't represent a scenario where you want all three of them (min-width
, width
and max-width
).
My preference would be a three-argument minmax
where the first argument would be the min-width
equivalent, the second the width
equivalent, and the third and last the max-width
equivalent. This would allow you to size a column as 1fr but not smaller than 200px and not bigger than 500px minmax(200px, 1fr, 500px)
@FremyCompany So making minmax()
essentially the same as clamp()
? But behaving *slightly different for grid, allowing fr
units and the option for only 2 arguments (min/max)? If this is the case, would just replacing clamp()
with minmax()
across the board make sense?
@FremyCompany That's what we're considering for the "1fr in min position" case (#2611), but that doesn't seem relevant for this issue.
@tabatkins Yes, this is only relevant now that we resolved #2611
But note that the idea is that a minmax
with three values like above means that both 200px
and 1fr
are minimums (whichever is bigger wins) not just 1fr
. And that, while retaining a 500px maximum.
@jonjohnjohnson Yes, this is clamp
but that allows mixing fr
and length-percentage
. I wouldn't mind renaming clamp
to minmax
or vice-versa, since no browser has support for it. I find minmax
more intuitive but this is subjective and not all that important.
I wouldn't mind renaming
clamp
tominmax
or vice-versa, since no browser has support for it.
Things have changed since that comment. clamp()
is now supported everywhere. So replacing it by minmax
isn't an option anymore. So, what about using clamp()
in this context?
Sebastian
How about adding a new parameter? Just like
minmax(min-value, max-value, more-prior-item)
The third parammore-prior-item
specifies which one has the priority.eg.
minmax(20%, 250px, 'min')
is equal tominmax(20%, 250px)
eg.minmax(20%, 250px, 'max')
makes max wins over min, which could solve the maxwidth situation.
I like this approach. However, the 'min'
case would be redundant because it's the default.
It could work only with specifying max
.
What do you think?
A keyword for the case where the minimum value wins is redundant but it also allows to be more explicit.
Sebastian
https://lists.w3.org/Archives/Public/www-style/2016Oct/0076.html
This is a perfectly reasonable use case, but since min wins over max in CSS in general, we weren't able to solve it by inverting the priority (see response on www-style). So we need some other, syntactically-different, solution. Suggestions welcome.