Fixed position is relative to parent container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Fixed position is relative to parent container

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">
div.fixed {<!--from w  ww .j a  v  a  2  s .  c  om-->
   position:fixed;
   top:100px;
   width:31px;
   height:31px;
   border:4px solid Chartreuse;
   background-color:yellow;
}

div.fixed2 {
   position:fixed;
   top:11px;
   left:11px;
   width:31px;
   height:31px;
   border:4px solid blue;
   background-color:pink;
}
</style> 
 </head> 
 <body> 
  <div class="fixed"> 
   <div class="fixed2"></div> 
  </div>  
 </body>
</html>

Related Tutorials