Why It's Not Working
fitColumns
is a "horizontal layout", so it's intended to go off to the side instead of up and down - similar to a side-scroller game. Given their design, horizontal layouts require a height attribute, as documented here: http://isotope.metafizzy.co/layout-modes.html#horizontal-layouts
Static Solution
I want to fill up the width of the container with however many columns fit, and I want it to take up as much vertical space as it needs to.
You want to use masonry
instead of fitColumns
. Setting the columnWidth
will allow you to fill the width of the container and use as much vertical space as necessary. For example: http://jsfiddle.net/cUcFd/22/
$('#container').isotope({
itemSelector : '.block',
// layoutMode: 'fitColumns',
layoutMode: 'masonry',
masonry: {
columnWidth: 100
}
});
Dynamic Solution
Assuming you don't know the width of your columns and want to find it dynamically, you could base it off the widest element in #container
using something like the code provided here: https://mcmap.net/q/1118511/-calculate-largest-width-of-a-set-of-elements-using-jquery
For example: http://jsfiddle.net/cUcFd/24/
var column_width = Math.max.apply(null,$('#container .block').map(function(){return $(this).outerWidth(true);}).get());
However, it will be up to you to determine the most appropriate method of setting the column width.