Ariona Rian Ariona Rian - 1 year ago 120
CSS Question

How to Create Grid/Tile View with CSS?

For example, I have some class .article, and I want to view this class as grid view. So I applied this style:


that style will make the .article look tiled/grid. it's work fine with fixed height. but if i want to set the height to auto (automatically stretch according to the data within it), the grid look nasty.
enter image description here

and i want to make the view like this :
enter image description here

Answer Source

This type of layout is called Masonry layout. Masonry is another grid layout but it will fill out the whitespace caused by the difference height of elements.

jQuery Masonry is one of jQuery plugin to create masonry layout.

Alternatively, you can use CSS3 columns. But for now jQuery based plugin is the best choice since there is compatibility issue with CSS3 column.