HTML Element Style 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'>
* {<!--from   w ww . ja  v  a 2  s.  c  o  m-->
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  display: table;
}

div {
  width: 100%;
  background: yellow;
  display: table-row;
}

div+div {
  background: pink;
  height: 100%;
}
</style>
</head>
<body>
  <div>hello</div>
  <div>there</div>
</body>
</html>

The code above is rendered as follows: