I run into this problem a lot when making grids of thumbnails, etc. When you try to center using margin: auto;
Normally, I will just use PHP and a counter to style the last object in each row without a margin on the right. But this is somewhat complicated, and I was hoping there might be a simpler way to do it using a CSS trick or something.
I’ve whipped up a stupid little example of the problem here http://jsfiddle.net/convoke/kFzg5/27/
And here’s what I’d like it to look like http://jsfiddle.net/convoke/NZR9X/3/
Subtle difference to the centering of the parent object, but hopefully you see what I mean.
I replaced floats to inline-blocks + justified “text”:
http://jsfiddle.net/kFzg5/28/
Warning: older browsers does not love this technique, and the last row looks fugly.
Second “solution” with extra wrapper div and much
overflow: hidden:http://jsfiddle.net/kFzg5/29/