CSS Layout How to - 2nd div to take remaining height








Question

We would like to know how to 2nd div to take remaining height.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.a {<!--from w  w w  .java2s  .  com-->
  display: table;
  height: 100px;
  width: 100px;
  background: green;
}

.b {
  width: 100px;
  background: yellow;
  display: table-row;
}

.c {
  background: pink;
  display: table-row;
  height: 100%;
  width: 100px;
}
</style>
</head>
<body>
  <div class="a">
    <div class="b">something</div>
    <div class="c">something else</div>
  </div>
</body>
</html>

The code above is rendered as follows: