I creating some code for showing box with diffrent heights (height will be from images inside).
In this example works perfectly: http://jsfiddle.net/GSnfG/
.
No, it's not possible to handle this in the general case without JavaScript or a server-side language.
In some cases, you can add wrapper div
s for each separate column, but some combinations of element size will make this look bad, for example: http://jsfiddle.net/suaaK/3/ - in that demo, it would probably be better if Box 6 was under Box 3. The more (and more differently sized) elements you have, the more uneven the columns can become.
See this answer for a comparison of the candidate techniques, showing that they don't work, and also showing the client-side portion of the solution involving server-side code:
If you're willing to use JavaScript+jQuery, you should use jQuery Masonry.
There's also a raw JavaScript version: Vanilla Masonry
Demos: