CSS Layout How to - Create single column layout with header and content








Question

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

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#main {<!--from w  ww  . j ava 2 s .c om-->
  width: 1000px;
  min-height: 1000px;
  height: auto;
  position: absolute;
  left: 170px;
  overflow: hidden;
  border: 1px dotted blue;
}

#header {
  width: 100%;
  height: 250px;
  background:#EEE;
}

#content {
  width: 100%;
  height: 1000px;
  position: relative;
  top: 20px;
  background:#AAA;
}
</style>
</head>
<body>
<body>
  <div id='main'>
    <div id='header'>header</div>
    <div id='content'>content</div>
  </div>
</body>
</body>
</html>

The code above is rendered as follows: