Position absolute but relative to parent - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Position absolute but relative to parent

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">
.childrens<!--from   ww w. j  av a 2  s.com-->
 {
   position:absolute;
   background-color:Chartreuse;
   height:201px;
   border:3px solid yellow;
}

#child1
 {
   right:0;
   top:21px;
}

#child2
 {
   float:left;
   top:41px;
}

#child3
 {
   top:71px;
   left:51%
}

#mainall
 {
   background-color:blue;
   height:151px;
   overflow:scroll
}
</style> 
 </head> 
 <body> 
  <div id="mainall"> 
   <div id="child1" class="childrens">
     Lorem ip 
   </div> 
   <div id="child2" class="childrens">
     Lorem ip 
   </div> 
   <div id="child3" class="childrens">
     Lorem ip 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials