Align elements in div vertical, alignment - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Div Align

Description

Align elements in div vertical, alignment

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">
.container {<!--from   w w w  . j av a2s .c  o  m-->
   background:gray;
   height:301px;
   width:100%;
   position:relative;
}

.container>div {
   height:100px;
   width:100px;
   position:absolute;
}

div.left {
   background:green;
   left:0;
   bottom:0;
   height:251px;
}

div.middle {
   background:red;
   left:100px;
   bottom:0;
   top:51%;
   margin-top:-51px;
}

div.right {
   background:blue;
   right:0;
   top:51%;
   margin-top:-51px;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="left"> 
   </div> 
   <div class="middle"> 
   </div> 
   <div class="right"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials