How to Create Grid/Tile View with CSS?

Tags: css,grid,positioning,css-float,tiles

Problem :

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

Solution :

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.

    CSS Howto..

    How do I set the width of inputs within a column in Twitter Bootstrap's grid system?

    How do I refactor my CSS? [duplicate]

    how i can fit text to an image with css

    How to exclude specific the form from the css applied to body [duplicate]

    How to reset margin-bottom to its default value

    How to force a list to be vertical using html css

    How to change text color of a link inside jQuery accordion

    How to center an image in an img tag using CSS background position

    How to override default tag css to normal?

    How to change HTML markup structure using javascript or CSS?

    How to manage assets for modern/ancient browsers

    How to add specific CSS attributes to all text-containing elements

    How to add dynamic CSS style sheet for single xhtml file

    How do I make a div not display, if the browser window is at a certain width? [duplicate]

    How do I set jQuery accordion default to unopened? And toggle open/closed?

    How to separate form with horizontal line

    How to convert an element css to JSON? [duplicate]

    How to simulate multiple
    tag with CSS

    How to make a sliding dashboard similar to [closed]

    How to float left without wrapping to next line?

    How to style form elements unobtrusively with JavaScript and CSS?

    How to give the color to * without using span Tag

    How does Mozilla create this animated effect?

    How can I caption an image inside a paragraph


    draggable without jquery ui: how to stop dragging the not-draggable and type-able elements?

    How to set backgroundImage property in css file in flex 4?

    How to remove captcha image and it's textbox using css?

    show a div over another when resizing on hover

    How to add threshhold onclick() jQuery?

    How to get parent DIV width and set child DIV width