The CSS Flexible Box module was created for this type of thing. See a quick example: " http://jsfiddle.net/c6QLC/2/ (look at this in Firefox)
Now the bad news is: you cannot yet rely on it. Not only does the replica correspond with each other, the current implementation does not support box-lines (which I included in the example), which will allow the elements to be on several lines rather than overflowing.
The new specification is written in the dev version of some browsers, so this will happen. It is just a matter of time.
At the same time, perhaps something like Isotope may suit your needs.
If you want to check the specification, you can find it here: http://www.w3.org/TR/css3-flexbox/
stephenhay
source share