CSS Layout How to - Make Div tag Content Appear Beneath a Fixed DIV Element with spacer div








Question

We would like to know how to make Div tag Content Appear Beneath a Fixed DIV Element with spacer div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#fixed-menu {<!--from   w ww .j  a va  2  s  .  c  om-->
  position: fixed;
  width: 100%;
  height: 75px;
  background-color: #EEE;
  padding: 10px;
}

.spacer {
  width: 100%;
  height: 95px;
}

#content {
  width: 100%;
  height: 600px;
  background-color: #DDD;
  padding: 10px;
}
</style>
</head>
<body>
  <div id="fixed-menu">Navigation options or whatever.</div>
  <div class="spacer">&nbsp;</div>
  <div id="content">Content.</div>
</body>
</html>

The code above is rendered as follows: