http://isotope.metafizzy.co/docs/help.html says:
First item breaks Masonry layout
With Masonry layout mode If you run into an issue where you re-size the first item, and all the rest of the items no longer fit together in the grid, you most likely need to set columnWidth option. Without columnWidth set, the Masonry layout mode will use the width of the first item for the size of its columns.
$('#container').isotope(
masonry: {
columnWidth: 220
}
});
And this is what I'm currently doing. However I would like to have some CSS media queries that change the columnWidth. So if my first Isotope-item would have the normal 1x width, I could just specify the width of the items in the CSS and Isotope would take the columnWidth from there and work. But because my first item has 2x width, I have to specify the column width like in the code above, and of course then I can no longer change it with CSS.
So is it possible to for example:
You could just use CSS and media queries to set the size of your elements, then access that value in Javascript and use it to set the column width:
var colWidth = $('.column-width-isotope-element').width();
$('#container').isotope(
masonry: {
columnWidth: colWidth
}
});
That way, the media query will be processed before isotope is initialized, and then it read the value of the column width (replace .column-width-isotope-element with whatever your selector is for a single-column width isotope element) and initialize isotope with that property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With