Page Widget How to - Create single column layout with header, footer and content








Question

We would like to know how to create single column layout with header, footer and content.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
html, body {<!--from   www.  j av a 2  s  . c  o  m-->
  height: 100%;
  padding: 0;
  margin: 0;
}

body {
  padding-top: 100px;
  background-color: gray;
}

header, footer {
  width: 100%;
  height: 100px;
  padding: 0;
  margin: 0;
}

header {
  position: absolute;
  top: 0;
  left: 0;
  background-color: red;
}

.main-content {
  width: 100%;
  height: 100%;
  background-color: gold;
}

footer {
  background-color: green;
}
</style>
</head>
<body>
  <header>
    <h1>Header</h1>
  </header>
  <div class="main-content">Main Content</div>
  <footer>Footer</footer>
</body>
</html>

The code above is rendered as follows: