center a grid of divs - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div Table

Description

center a grid of divs

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor sit amet, co</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.container<!--from   ww  w. j a v  a2s  .c om-->
 {
   text-align:center;
}

.block
 {
   display:-moz-inline-stack;
   display:inline-block;
   vertical-align:top;
   zoom:2;
   *display:inline;
   width:251px;
   height:100px;
   background:Chartreuse;
   margin:2%;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
   <div class="block"></div> 
  </div>  
 </body>
</html>

Related Tutorials