HTML fixed header bar when scroll - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Header

Description

HTML fixed header bar when scroll

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  w  w  .ja  v  a2s  .c o  m-->
   margin:0; padding:0; height:100%; width: 100%; position:relative; overflow-x: hidden; overflow-y: hidden
}
html {
   width: 100%; height: 100%; margin-left: 0px; margin-right: 0px; overflow-x: hidden; overflow-y: hidden";
}
.home {
   width: 100%; height:100%; overflow-y: scroll;
   margin-top: 100px;
}
div.header {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
}


      </style> 
 </head> 
 <body> 
  <div class="header" style="width:100%; text-align: center; background: #000000; padding-top: 4%; padding-bottom: 4%;"> 
   <p style="vertical-align: middle; color: white">Head Bar</p> 
  </div> 
  <div class="home"> 
   <img src="https://www.java2s.com/style/demo/Safari.png" style="width:100%; height:30%; max-height:30%;"> 
   <div> 
    <p>Title 1</p> 
    <p>Content 1</p> 
    <p>Author: Alex</p> 
   </div> 
   <img src="https://www.java2s.com/style/demo/Safari.png" style="width:100%; height:30%; max-height:30%;"> 
   <div> 
    <p>Title 2</p> 
    <p>Content 2.</p> 
    <p>Author: Alex</p> 
   </div> 
   <img src="https://www.java2s.com/style/demo/Firefox.png" style="width:100%; height:30%; max-height:30%;"> 
   <div> 
    <p>Title 3</p> 
    <p>Content 3.</p> 
    <p>Author: Alex</p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials