CSS height issue with flex box inside flex box CSS height issue with flex box inside flex box google-chrome google-chrome

CSS height issue with flex box inside flex box


Generally speaking, 100% height works when the parent has a well defined height. In your example, the outermost app-content does not have an explicit height which is why 100% height on its child does not work.

A simple workaround is to use relative-absolute positioning to size the child:

#container {  position: absolute;  height: 100%;  width: 100%;  border: 3px solid yellow;}.app {  display: flex;  flex-direction: column;  height: 100%;  border: 3px solid black;}.app-header {  border: 3px solid red;}.app-content {  border: 3px solid green;  flex: 1;  /* added property */  position: relative;}.app-footer {  border: 3px solid blue;}/* added rule */.app-content > .app {  height: auto;  position: absolute;  left: 0;  right: 0;  top: 0;  bottom: 0;}/* scrollbar and border correction */body {  margin: 0;  padding: 0;}div {  box-sizing: border-box;}
<div id="container">  <div class="app">    <div class="app-header">HEADER1</div>    <div class="app-content">      <div class="app">        <div class="app-header">HEADER2</div>        <div class="app-content">CONTENT2</div>        <div class="app-footer">FOOTER2</div>      </div>    </div>    <div class="app-footer">FOOTER1</div>  </div></div>