Relatively positioned element in front of fixed element - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Relatively positioned element in front of fixed element

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 ww  .ja  v a2s  .c om-->
   background-color:Chartreuse;
   position:absolute;
   top:0;
   left:0;
   width:100%;
   height:51px;
}

.hook {
   background-color:yellow;
   position:fixed;
   top:0;
   left:0;
   width:201px;
   height:51px;
}

.navbar {
   background-color:blue;
   position:absolute;
   top:0;
   left:0;
   width:51px;
   height:100%;
}

.content {
   background-color:pink;
   position:relative;
   top:0;
   left:0;
   width:100px;
   height:51px;
}
</style> 
 </head> 
 <body> 
  <div id="header">
    Lorem ipsu 
  </div> 
  <div class="hook">
    Lorem i 
  </div> 
  <div class="navbar">
    Lorem ipsu 
  </div> 
  <div class="content">
    Lorem ipsu 
  </div>  
 </body>
</html>

Related Tutorials