Add fixed bar to HTML page with position:fixed; - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Add fixed bar to HTML page with position:fixed;

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">
#header {<!--from w  w  w .  ja v  a 2s .c om-->
   position:fixed;
   top:0px;
   background:Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div id="header"> 
   <h1> HEADER: Long header. </h1> 
  </div> 
  <div id="content"> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
   <p> Content...</p> 
  </div> 31  
 </body>
</html>

Related Tutorials