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-sizing] Should aspect-ratio: <ratio> obey box-sizing on replaced elements with auto preferred sizes? #11093

Open
Loirooriol opened this issue Oct 25, 2024 · 1 comment

Comments

@Loirooriol
Copy link
Contributor

So my understanding from #4951 and https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio is that these tests are wrong:

Since aspect-ratio doesn't have auto, then it should obey box-sizing.

But of course the tests are part of interop-2021 and all browsers are passing them.

I'm not sure if there has been some amendment to align with browsers.

@Loirooriol
Copy link
Contributor Author

So to be specific, https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio says

The tests have the default min-width: auto that behaves as 0, which is floored to 80px to avoid a negative content width, then this is transferred to a min border-box height of 80px / (20/50) = 200px. But the tests expects 100px instead.

Browsers are passing the tests for different reasons:

  • Gecko totally ignores aspect-ratio: <ratio> (treats it as auto) on replaced elements with width: auto; height: auto.

  • WebKit obeys aspect-ratio: <ratio>, but on replaced elements with width: auto; height: auto it applies the ratio to the content-box regardless of box-sizing, e.g.

    <style>canvas { aspect-ratio: 10/25; background: green; padding-right: 40px; padding-bottom: 25px; box-sizing: border-box }</style>
    <canvas width="10" height="25" style="min-width: 40px; width: auto"></canvas>
    <canvas width="10" height="25" style="min-width: 40px; width: 0px"></canvas>

    imatge

  • Blink obeys aspect-ratio: <ratio> and respects box-sizing, but only when a min/max constraint is violated, e.g.

    <style>canvas { aspect-ratio: 10/25; background: green; padding-right: 40px; padding-bottom: 25px; box-sizing: border-box; }</style>
    <canvas width="10" height="25" style="min-width: 50px"></canvas>
    <canvas width="10" height="25" style="min-width: 51px"></canvas>

    imatge

Agenda+ to ratify the spec or align with some browser.

@Loirooriol Loirooriol changed the title [css-sizing] Has #4951 been amended by a later resolution? Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant