You can use the popular Masonary library.
Dynamic Link Plugin for jQuery Flip Side CSS Posters
Here is an example code ...
$('#container').masonry({ itemSelector: '.box' });
Here's a source on Github and an interview with David Desandro in the Shoptalk podcast.
Tip: Make sure that the parent container has the position: relative, so all content is bound to your container.
source share