0

According to the documentation on CSS-tricks, using justify-content: stretch, a flexbox child item should stretch within its container to fill the available space. I have a flexbox container where I set the main axis to be column direction, then in this container I place two div flexbox items. I want them to fill the available vertical space equally (so I believe flex: 0 1 auto should do it).

Here is the JS fiddle:

body {
  height: 100%
}

.container {
  height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  border: 1px solid grey;
}

.in {
  height: 25px;
  border: 1px solid black;
  flex: 0 1 auto;
}
<div class="container">
  <div class="in">Inside</div>
  <div class="in">
  Inside
  </div>
</div>
TMOTTM
  • 3,286
  • 6
  • 32
  • 63

1 Answers1

0

As pointed out by @Temani Afif:

body {
  height: 100%
}

.container {
  height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  border: 1px solid grey;
}

.in {
  height: 25px;
  border: 1px solid black;
  flex: 1 1 auto;
}
<div class="container">
  <div class="in">Inside</div>
  <div class="in">
  Inside
  </div>
</div>
SuperDJ
  • 7,488
  • 11
  • 40
  • 74