Page Widget How to - Layout with Fixed footer and header








Question

We would like to know how to layout with Fixed footer and header.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#header {<!--   ww  w .  j a v  a2s  .c o  m-->
  position: fixed;
  top: 0;
  height: 20px;
  width: 100%;
  background-color: #ff0000;
}

#footer {
  position: fixed;
  bottom: 0;
  height: 20px;
  width: 100%;
  background-color: #ff0000;
}

#content {
  position: absolute;
  top: 20px;
  bottom: 20px;
  width: 100%;
  background-color: #EEE;
  overflow: auto;
}
</style>
</head>
<body>
  <div id="header"></div>
  <div id="content">
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
    content<br />content<br />content<br />
  </div>
  <div id="footer"></div>
</body>
</html>

The code above is rendered as follows: