How can I make Flexbox children 100% height of their parent?

Raz picture Raz · Mar 13, 2013 · Viewed 706.8k times · Source

I'm trying to fill the vertical space of a flex item inside a Flexbox.

And here's the JSFiddle

flex-2-child doesn't fill the required height except in the two cases where:

  1. flex-2 has a height of 100% (which is weird because a flex item has a 100% by default + it is buggy in Chrome)
  2. flex-2-child has a position absolute which is also inconvenient

This doesn't work in Chrome or Firefox currently.

Answer

B T picture B T · Sep 8, 2015

Use align-items: stretch

Similar to David Storey's answer, my workaround is:

.flex-2 {
    display: flex;
    align-items: stretch;
}

Alternatively to align-items, you can use align-self just on the .flex-2-child item you want stretched.