Position relative, get rid of dead space - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Position relative, get rid of dead space

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">
#elementsinadiv {<!--from   www.  j av a 2s  . c o  m-->
   height:100px;
   width:201px;
   background-color:Chartreuse;
   overflow:hidden;
}

.myelement {
   position:relative;
   display:block;
   height:51px;
   width:100px;
   border:2px solid yellow;
   background-color:blue;
}
</style> 
 </head> 
 <body> 
  <div id="elementsinadiv"> 
   <div class="myelement">
     Lorem ipsum 
   </div> 
   <div class="myelement">
     Lorem ipsum 
   </div> 
   <div class="myelement">
     Lorem ipsum 
   </div> 
   <div class="myelement">
     Lorem ipsum 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials