Margins for position absolute/relative - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Margins for position absolute/relative

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 {<!--   ww  w .  ja  v a 2s . c  o m-->
   width:781px;
   margin:21px auto;
}

#container {
   border:6px solid Chartreuse;
   position:relative;
}

#firstDiv {
   border:6px solid yellow;
   width:761px;
   margin-bottom:41px;
}

#secondDiv {
   border:6px solid blue;
   position:relative;
   margin-top:41px;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="firstDiv">
     Lorem ipsum dolor sit amet, 
   </div> 
   <div id="secondDiv">
     Lorem ipsum dolor sit amet, c 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials