-
Notifications
You must be signed in to change notification settings - Fork 693
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-values] max() issue #11768
Comments
It's important to keep types consistent, e.g. I think your usecase would be better addressed by block-size: calc((100lvh - 3.75rem - 4.75rem) / 24);
min-block-size: 3rem; |
This is actually failing before the "consistent type" is even checked. See https://drafts.csswg.org/css-values-4/#determine-the-type-of-a-calculation - the unknown unit has a type of "failure", and this percolates up thru the entire expression, causing it to fail to match any of the types like This is identical to the behavior if you use the unknown unit outside of a math expression: There are several ways to deal with this today - an @property --lvh {
syntax: "<length>";
initial: 1vh; /* a dependable fallback */
inherits: true;
}
:root {
--lvh: 1lvh; /* the actual value you want to use */
}
...elsewhere...
block-size: max(3rem, calc((100--lvh - 3.75rem - 4.75rem) / 24)); |
@tabatkins thanks for the details, really appreciated. :) |
Hello there,
I'm Nico, one of Proton Mail/Calendar devs. I encountered an issue on some old browsers that do not support
lvh
unit in amax
comparison, and I'd like to make sure I understood the spec correctly, and if it's the case, to propose something.I did use something like:
block-size: max(3rem, calc((100lvh - 3.75rem - 4.75rem) / 24))
in our codebase.We discovered that on some old browsers that don't support
lvh
unit that themax
comparison was totally failing. I though firstmax(3rem, <something not supported>)
would go to3rem
, but it seems we must have a consistent type or else the function is invalid https://drafts.csswg.org/css-values/#comp-funcFirst => could you confirm I properly understood the spec here?
Second => proposal: would it make sense in these cases that when we compare
a value
andsomething not supported
that the result would default to the properly defined value?For sure we can wrap stuff in an
@support (@supports (block-size: (max(1rem, 100lvh))))
to make sure we supportmax
andlvh
(what we did). But TBH, I found it a bit too much, I was thinking that comparingmax(3rem, <something not supported>)
should go to3rem
, just for graceful degradation/progressive enhancement purposes :)Thanks,
The text was updated successfully, but these errors were encountered: