11

I have set up masonry to display items as such:

$('#list').masonry({
  itemSelector: '.propitem',
  columnWidth: 230
});

This works, but all items (.propitem) float to the left. For example if my container #list is 600px wide there will be two columns to the left but a gap to the right of them where the remaining 140px is. I would like to center the 2 columns with a 70px 'margin' on either side.

I have tried using css to centre these, but had no luck, eg:

#list {
text-align: center;
}

Would anyone know the correct way of achieving this?

MeltingDog
  • 11,060
  • 34
  • 130
  • 238

1 Answers1

17

You need to use fitWidth (or, in older versions, isFitWidth) along with CSS to make it work. Here's the reference: http://masonry.desandro.com/options.html#isfitwidth

$('#list').masonry({
  itemSelector: '.propitem',
  columnWidth: 230,
  fitWidth: true
});

and

#list {
  margin: 0 auto;
}
ralph.m
  • 12,558
  • 3
  • 19
  • 29