Page Widget How to - Stretch sidebar to the page length








Question

We would like to know how to stretch sidebar to the page length.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#parentDiv {<!-- w  w  w  .  j a  v a2  s  .  c om-->
  position: relative;
  border-style: solid;
  min-height: 700px;
}

#content {
  width: 300px;
}

#sidebar {
  position: absolute;
  top: 0px;
  right: 0px;
  bottom: 0px;
  width: 100px;
  background-color: red;
}
</style>
</head>
<body>
  <div id="parentDiv">
    <div id="content">Content here....</div>
    <div id="sidebar"></div>
  </div>
</body>
</html>

The code above is rendered as follows: