Aligning a list of divs in the centre of the page - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Div Align

Description

Aligning a list of divs in the centre of the page

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">
.content {<!--from  w w w . j  a  v a  2s  . co  m-->
   margin:auto;
}

.content div {
   text-align:center;
}

#divone {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:Chartreuse;
}

#divtwo {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:yellow;
}

#divthree {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:blue;
}

#divfour {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:pink;
}

#divfive {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:WhiteSmoke;
}

#divsix {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:repeat;
   background-color:OrangeRed;
}
</style> 
 </head> 
 <body> 
  <div class="content"> 
   <div id="divone">
     Content here 
   </div> 
   <div id="divtwo">
     Content here 
   </div> 
   <div id="divthree">
     Content here 
   </div> 
   <div id="divfour">
     Content here 
   </div> 
   <div id="divfive">
     Content here 
   </div> 
   <div id="divsix">
     Content here 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials