I wanted to make a grid where blocks automatically move to the next line when the grid becomes too small. It works like this: http://jsfiddle.net/nbmt54nn/5/ (try resizing the window so that the blocks move to the next line).
The problem is that the grid should wrap tightly around the blocks, leaving no extra space on the right side, or at least, center the imaginary square around the blocks while keeping a left-align for the individual blocks.
Is this possible? And if so, please elaborate on how to do so. If it is not possible, I would like some advice on how it could be done best. Your help is appreciated.
A workaround I am using now is to compute the grid's width and use media queries to adjust the grid's width to equal the width of n
blocks, where n * (block-width + 2 * block-margin) + other-elements
should be less than the page-width.