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] It's false that height: stretch behaves as stretch alignment #11784

Open
Loirooriol opened this issue Feb 26, 2025 · 1 comment
Open

Comments

@Loirooriol
Copy link
Contributor

Loirooriol commented Feb 26, 2025

https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing

We have interoperability against this:

<!DOCTYPE html>
<style>
.container { display: inline-flex; vertical-align: top; width: 100px; height: 100px; border: solid; flex-wrap: wrap; align-content: start }
.stretch { height: -moz-available; height: -webkit-fill-available; height: stretch }
</style>
<div class="container">
  <div class="stretch" style="width: 75px; border: solid cyan">a</div>
  <div class="stretch" style="width: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div class="stretch" style="width: 75px; border: solid cyan">a</div>
  <div style="border: solid orange; height: 150px"></div>
  <div class="stretch" style="width: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div style="width: 75px; border: solid cyan;">a</div>
  <div style="width: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div style="width: 75px; border: solid cyan;">a</div>
  <div style="border: solid orange; height: 150px"></div>
  <div style="width: 75px; border: solid magenta">b</div>
</div>

Gecko, Blink and WebKit agree:

  • When computing the size of the flex lines: height: stretch stretches against the containing block, while align-self: stretch doesn't stretch.
  • Once we know the size of the flex lines: height: stretch keeps stretching against the containing block, while align-self: stretch stretches against the line.

If the flex container doesn't have a definite height (remove height: 100px):

  • Gecko and Blink don't stretch height: stretch, neither when computing line sizes nor once we know their size. align-self stretches in the latter one:

  • WebKit does that thing of stretching all ancestors with indefinite size, in this case filling the window:

@Loirooriol
Copy link
Contributor Author

BTW, same for a column flexbox:

<!DOCTYPE html>
<style>
.container { display: flex; flex-direction: column; width: 100px; height: 100px; border: solid; flex-wrap: wrap; align-content: start }
.stretch { width: -moz-available; width: -webkit-fill-available; width: stretch }
</style>
<div class="container">
  <div class="stretch" style="height: 75px; border: solid cyan">a</div>
  <div class="stretch" style="height: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div class="stretch" style="height: 75px; border: solid cyan">a</div>
  <div style="border: solid orange; width: 150px"></div>
  <div class="stretch" style="height: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div style="height: 75px; border: solid cyan;">a</div>
  <div style="height: 75px; border: solid magenta">b</div>
</div>
<div class="container">
  <div style="height: 75px; border: solid cyan;">a</div>
  <div style="border: solid orange; width: 150px"></div>
  <div style="height: 75px; border: solid magenta">b</div>
</div>

With width: min-content; max-width: 100px:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant