I need to come like this:
The ammount of blocks can be different.
Since this question is tagged with css3 I am going to suggest a css3 solution.
Demo: http://jsfiddle.net/mqchen/VEmCK/
.wrap {
display: -webkit-box; /* OLD: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* OLD: Firefox (buggy) */
display: -ms-flexbox; /* MID: IE 10 */
display: -webkit-flex; /* NEW, Chrome 21+ */
display: flex; /* NEW: Opera 12.1, Firefox 22+ */
border: 1px solid black;
padding: 1px;
float: left;
width: 100%;
clear: both;
margin-bottom: 20px;
}
.box {
-ms-box-flex: 1;
-ms-flex: 1;
-moz-box-flex: 1;
-moz-flex: 1;
-webkit-box-flex: 1;
-webkit-flex: 1;
box-flex: 1;
flex: 1;
border: 1px solid red;
padding: 5px 40px;
margin-right: 30px;
}
.wrap .box:last-child {
margin-right: 0;
}
(You need to tweak the sizes for your own use, but I think this gives a rough idea on how it might work for you.)
This solution uses flexbox
for aligning the boxes. You can read more about it here: http://coding.smashingmagazine.com/2013/05/22/centering-elements-with-flexbox/
Why flexbox or JS solutions? You can accomplish this using display: table and display: table-cell;
<div class="row">
<div>1</div>
<div>2Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div>3</div>
</div>
.row { display: table; width: 100%; }
.row div { display: table-cell; width: 1%; }
You need to write a script that does a count for how many divs you have and then divide by 100 and assign that as a width. If you really wanted to do it right you could also use foundation css framework to do the calculations for you (at least the widths).
I've seen this a few times, and this is the best way to solve this in my opinion: Fluid width with equally spaced DIVs
Basically you use a span with a stretcher class at the bottom of your list and you add a 'text-align:justify' on your ul/container element for your nav.
<div id="container">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<span class="stretch"></span>
</div>
Here's a demo: http://jsfiddle.net/thirtydot/EDp8R/