-
Notifications
You must be signed in to change notification settings - Fork 711
[css-sizing-4] aspect-ratio min-content size with % width #5549
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
Comments
Having consistency with replace elements (at least when |
Whether an element is replaced or not is an independent question from whether it has an aspect ratio. Even if you have a replaced element without an aspect ratio, its min-content contribution still gets zeroed out by a percentage size or max-size. Also, That said, I can see why the “replaced element with percentage width has zero min-content size” rule is desired outside of replaced elements. |
Note, the spec for this special behavior is here: https://drafts.csswg.org/css-sizing-3/#replaced-percentage-min-contribution |
As in #5537, it would help a lot if I could understand what the desired behavior here was, and why. Right now I'm just looking at a series of testcases showing various behaviors, with no explanation of what's expected or desired and why. It looks like @dvoytenko is trying to use these properties to make an element act like a replaced element. Is this right? If so, why? It is def the case that c-i-s shouldn't have any relevance here; the behavior you get from contain:size and c-i-s should be identical to the behavior you get from a normal element with enough content to produce the same size. So this is purely a question about aspect-ratio. |
This might be a use case for the |
Yes, it seems very plausible that that's the control we want here. |
So, our proposal is to a) close this issue no change b) describe the use case for zeroing out the min-content contribution in #4585 and try to solve by adding a new switch there. @dvoytenko - does this sound reasonable to you? Would you mind posting an explanation of your use case in #4585? |
Not sure yet if this is the same as #4585. The demos that I made are the solutions I collected to build aspect ratio for different layouts in a pre-aspect-ratio world. What you see in the "Emulated" section are some very common solutions they are employed right now. I'm trying now to build the path from these "old" solutions to the new aspect ratio, which should help either with transition or possibly even shimming the |
Possible alternative solution in #5573 |
@cbiesinger I think it would be better to go for a more generally-applicable solution in #4585, since that would solve similar cases even when |
Looking at the "bound width and height" example, the markup is real confusing because it's using abspos on the element to make it fill the parent (and the interaction between abspos with non-auto insets and aspect-ratio, it turns out, isn't well-defined; the Position and Sizing specs both try to define the automatic sizes), but if I unset all of those properties... I can end up with an empty block element, with a set aspect-ratio (say, The bug here is that sizing constraints are meant to transfer across the ratio as well; search for "Additionally, sizing constraints in either axis" in https://drafts.csswg.org/css-sizing-4/#aspect-ratio. This means the |
@tabatkins to confirm: right now the bound width/height is working correctly in Chrome. Are you saying it shouldn't? |
Right now, the behavior in Chrome is what I described above: an element with |
Ah, what I'm describing is the behavior of Chrome 85. In Chrome 87 (per Dima), things are fixed to act like how I described they should per spec: the elements don't fill the entire parent, and instead shrink to maintain their aspect-ratio while respecting the max-* constraints. Yay! |
Closing this out under the concept that |
https://drafts.csswg.org/css-sizing-4/#aspect-ratio
Usually, aspect-ratio is supposed to behave like a replaced element with that ratio. However, there is one behavior difference:
If a replaced element has a percentage width, the min-content size becomes 0:
https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/layout/layout_replaced.cc;l=912;drc=df8f58d9311eb29e65394e437a156b00fafc9a67;bpv=1;bpt=1
This is not the case with aspect-ratio, and when combined with contain-intrinsic-size this can lead to undesired effects, quoting from an email I got:
Should this behavior be spec'd for aspect-ratio?
@dvoytenko @bfgeek @fantasai
The text was updated successfully, but these errors were encountered: