Header and footer sticky - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Footer stick to bottom

Description

Header and footer sticky

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 {<!--from   w w  w.  ja v a  2 s. c om-->
   height:100%;
   background:url('https://www.java3s.com/style/demo/Google-Chrome.png') no-repeat top center fixed;
   margin:0;
   padding:0;
}

#wrapper {
   width:100%;
   min-height:100%;
}

#header {
   position:fixed;
   background:Chartreuse url('https://www.java3s.com/style/demo/Google-Chrome.png') no-repeat top center fixed;
   top:0;
   height:100px;
   width:100%;
   z-index:1001;
}

#main {
   position:relative;
   top:100px;
   width:991px;
   left:0;
   right:0;
   overflow:auto;
   margin:0 auto;
   padding-bottom:151px;
   padding-top:11px;
   padding-left:6px;
   padding-right:6px;
}

#footer {
   position:fixed;
   bottom:0;
   background-image:url('https://www.java3s.com/style/demo/Google-Chrome.png');
   background-color:yellow;
   height:151px;
   width:100%;
}
</style> 
 </head> 
 <body> 
  <div id="wrapper"> 
   <div id="header">
     Lorem ip 
   </div> 
   <div id="main"> 
    <p>Lorem ipsum dol</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum dolo</p> 
    <p>Lorem ipsum do</p> 
   </div> 
   <div id="footer"> 
    <p class="alignleft">Lorem</p> 
    <p class="alignright">Lorem ipsum d</p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials