I have an isotope grid with a non fixed width and I dont know how to center the items inside the isotope container.
.box{
width: 40px;
height: 40px;
background-color: #e74c3c;
margin: 0 auto;
}
that css fails to center the items. here is the link to the fiddle that illustrates my problem.
How can i make the red squares center inside the black box?
Easiest way is to use masonry:
jsFiddle
var $container = $('#container');
// init
$container.isotope({
// options
itemSelector: '.box',
masonry: {
columnWidth: 40,
isFitWidth: true
}
});
use masonry and add margin 0 auto to the grid.
js:
masonry: {
columnWidth: 100,
fitWidth: true
}
css :
.grid {
margin: 0 auto;
}
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