Align several nested div's of a div to the center - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Div Align

Description

Align several nested div's of a div to the center

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">
#parent {<!-- w w w .  j a va  2  s.  co  m-->
   float:left;
   height:100px;
   width:481px;
   margin-top:56px;
   text-align:center;
   border:2px solid Chartreuse;
}

.d {
   background:yellow;
   width:106px;
   margin:0 auto;
   border:2px solid blue;
}
</style> 
 </head> 
 <body> 
  <div id="parent"> 
   <div id="menu_0" class="d">
     Lorem Ipsum 
   </div> 
   <div id="menu_1" class="d">
     Lorem Ipsum 
   </div> 
   <div id="menu_2" class="d">
     Lorem Ipsum 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials