html - Floting divs around a center div (For a grid) -


i want make div grid bigger center div in middle, small divs won't wrap properly. must change? i'm trying not use tables because of bandwith , on.

my html:

<div id="main">      <!-- lot of .icon's here -->     <div class="icon"></div>     <div class="title"></div>     <div class="icon"></div>     <!-- lot of .icon's here -->  </div> 

my css:

#main {   display: inline-block;   margin: 5em 0 3em 0;   width: 66.2em;   height: 35.2em;   text-align: left;   overflow: hidden; }  .icon {   background: #000;   height: 5em;   width: 5em;   margin: 0 0.2em 0.2em 0;   display: inline-block; }  .title {   background: #777;   height: 10.2em;   width: 21.4em;   margin: 0 0.2em 0.2em 0;   display: inline-block; } 

thanks in advance!

here go: fiddle http://jsfiddle.net/fx62r/2/

inline-block leaves white-space between elements. use float: left; instead of inline block

write elements on same line avoid white-space. this:

<div class="icon"></div><div class="title"></div><div class="icon"></div>

and remove margin:

 .icon {      margin: 0 0.2em 0.2em 0;  //remove.   }   .title {       margin: 0 0.2em 0.2em 0; //remove      } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -