position a DIV in relation to another DIV - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

position a DIV in relation to another DIV

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>
#slides {<!-- ww w  .  j ava 2  s . co m-->
   width:601px;
   height:281px;
   background:yellow;
   position:relative;
}

p.title {
   font-size:29px;
   text-align:center;
   position:relative;
   top:41px;
}

p.description {
   text-align:center;
   position:relative;
   top:21px;
}

#button1 {
   width:151px;
   height:36px;
   background:blue;
   margin:0 auto;
   line-height:36px;
   text-align:center;
   position:relative;
   top:41px;
}

#button2 {
   width:86px;
   height:26px;
   background:red;
   line-height:26px;
   text-align:center;
   position:absolute;
   left:51%;
   margin-left:-43px;
   bottom:-13px;
}
</style> 
 </head> 
 <body translate="no"> 
  <div id="slides"> 
   <p class="title">Lorem ipsum dol</p> 
   <p class="description">Lorem ipsum dolor sit a<br>Lorem ipsum dolor sit a<br>Lorem ipsum dolor sit a<br>Lorem ipsum dolor sit a<br>Lorem ipsum dolor sit a<br> </p> 
   <div id="button1">
     Lorem ips 
   </div> 
   <div id="button2">
     Lorem ips 
   </div> 
  </div> 
  <!-- end slides -->  
 </body>
</html>

Related Tutorials