Div Position Fixed - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Div 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">
body, html {
   width:100%;
   height:100%;
}

body {<!--   www. j av a  2s  .c  om-->
   margin:0px;
   background:Chartreuse url('https://www.java2s.com/style/demo/Google-Chrome.png') repeat scroll 0 0;
   text-align:center;
}

.BG1 {
   width:100%;
   height:100%;
   position:fixed;
   z-index:2;
   top:0;
   left:0;
}

.BG1 .Data {
   width:501px;
   height:100%;
   margin-left:auto;
   margin-right:auto;
   border-left:3px solid yellow;
   border-right:3px solid blue;
}

.BG2 {
   width:100%;
   height:100%;
}

.BG2 #Header {
   width:100%;
   height:151px;
   position:fixed;
   z-index:2;
}

.BG2 #Header .Header_Data {
   width:100%;
   height:121px;
   overflow:hidden;
   background-image:-webkit-gradient(linear, left top, left bottom, from(pink), to(transparent));
   background-image:-webkit-linear-gradient(top, OrangeRed, transparent);
   background-image:-moz-linear-gradient(top, grey, transparent);
   background-image:-ms-linear-gradient(top, BlueViolet, transparent);
   background-image:-o-linear-gradient(top, Chartreuse, transparent);
   background-image:linear-gradient(top, yellow, transparent);
   filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='blue', endColorstr='transparent',GradientType=0 );
   border-bottom:3px solid pink;
   -webkit-box-shadow:inset 0 0 16px OrangeRed, 0 0 21px grey;
   -moz-box-shadow:inset 0 0 16px BlueViolet, 0 0 21px Chartreuse;
   box-shadow:inset 0 0 16px yellow, 0 0 21px blue;
}
</style> 
 </head> 
 <body> 
  <title>Lorem ips</title> 
  <div class="BG1"> 
   <div class="Data"></div> 
  </div> 
  <div class="BG2"> 
   <div id="Header"> 
    <div class="Header_Data"></div> 
   </div> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
   <br>Lor 
   <br> 
  </div>  
 </body>
</html>

Related Tutorials