2

Let's say I have following:

.wrap { height:400px; }
.header { height:100px; }
.footer { height:100px; }

<div class="wrap">
  <div class="header"></div>
  <div class="middle_row"></div>
  <div class="footer"></div>
</div>

Is there any CSS solution to have .middle_row be dynamically stretched to 200px?

Alex F
  • 183
  • 2
  • 14

2 Answers2

2

Yes, try Flexbox

.wrap {
  display: flex;
  height: 400px;
  flex-direction: column;
}

.header, .footer {
  flex: 0 0 100px;
  background: lightblue;
}

.middle_row {
  flex: 1;
  background: lightgreen;
}
<div class="wrap">
  <div class="header"></div>
  <div class="middle_row"></div>
  <div class="footer"></div>
</div>
Nenad Vracar
  • 118,580
  • 15
  • 151
  • 176
1

You can simply give it a height of 50%. This will set it to half its parent's height (400px / 2 = 200px).

.middle_row { height: 50%; }
James Donnelly
  • 126,410
  • 34
  • 208
  • 218