Centering boxes in CSS - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Box

Description

Centering boxes in CSS

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">
#boxes {<!--  ww  w .ja v  a 2 s  .  c  o m-->
   width:801px;
   background-color:Chartreuse;
   float:left;
   display:flex;
   justify-content:center;
}

#boxes .box {
   width:100px;
   height:100px;
   margin:11px;
   background-color:yellow;
}
</style> 
 </head> 
 <body> 
  <div id="boxes"> 
   <div class="box">
     Lorem 
   </div> 
   <div class="box">
     Lorem 
   </div> 
   <div class="box">
     Lorem 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials