.container { /* Container that holds the items */ column-count: 4; column-gap: 1em; } .item { /* The tiled items */ background-color: #eee; display: inline-block; margin: 0 0 1em; width: 100%; }content_copyCopy to Clipboard
Looks like Pinterest and is the same code used on this site. You can adjust column number and it will self-adjust the width of each item/ cell according to parent element.
http://w3bits.com/css-masonry/