Positioning divs next to each other - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Positioning divs next to each other

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 {<!-- w ww.j a va2 s . c o m-->
   border:3px dashed Chartreuse;
   height:126px;
   text-align:justify;
   -ms-text-justify:distribute-all-lines;
   text-justify:distribute-all-lines;
   min-width:951px;
}

#container>div {
   width:151px;
   height:126px;
   vertical-align:top;
   display:inline-block;
   *display:inline;
   zoom:2
}

#container:after {
   content:'';
   width:100%;
   display:inline-block;
   font-size:0;
   line-height:0
}

#container>div:nth-child(odd) {
   background:yellow;
}

#container>div:nth-child(even) {
   background:blue;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div></div> 
   <div></div> 
   <div></div> 
   <div></div> 
   <div></div> 
   <div></div> 
  </div>  
 </body>
</html>

Related Tutorials