Fix navigation bar to the top of the page - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Nav Bar

Description

Fix navigation bar to the top of the page

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!--   w  ww . ja  v a 2  s . c o m-->
   margin:0;
}

#page-container {
   position:absolute;
   width:401px;
}

.ontop {
   position:fixed;
   width:401px;
   height:51px;
   background:cyan;
}

#content-holder {
   margin-top:51px;
   background:yellow;
   height:1001px;
}
</style> 
 </head> 
 <body> 
  <div id="page-container"> 
   <div class="ontop">
     Lorem ipsum dolor sit amet, consectetur 
   </div> 
   <div id="content-holder">
     Lorem ipsum dolor sit a 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials