Make absolutely positioned divs 50% height of their parent - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Make absolutely positioned divs 50% height of their 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">
.table {<!--from   w  w w .jav a2  s  . c  om-->
   display:table;
   background-color:Chartreuse;
   border-spacing:11px;
}

.cell {
   display:table-cell;
   vertical-align:middle;
   position:relative;
   width:71%;
   width:31%;
}

.bottom,
.top {
   box-sizing:border-box;
   position:absolute
   display:inline-block;
   background-color:yellow;
   padding:15px;
   width:100%;
}

.bottom {
   bottom:0;
   top:51%;
   margin-top:6px;
}

.top {
   top:0;
   margin-bottom:11px;
}
</style> 
 </head> 
 <body> 
  <div class="table"> 
   <div class="cell">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, 
   </div> 
   <div class="cell"> 
    <div class="top">
      Lorem ips 
    </div> 
    <div class="bottom">
      Lorem ipsum 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials