How to use Masonry library

Posted By : Darshan Dang | 26-Jun-2015

What is Masonry?

Masonry is a JavaScript grid layout library. It works by placing elements in optimal position based on available vertical space.

Using Masonry is easy—just follow these simple steps:

HTML

 <script src="https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.0/masonry.pkgd.js"></script>
...
...
...
...

CSS 

Masonry works on a container grid element with a group of child items.

 .grid-item { width: 200px; }
.grid-item--width2 { width: 400px; }
 

jQuery 

 $('.grid').masonry({
  // options
  itemSelector: '.grid-item',
  columnWidth: 200
});
 

Example :

masonry-exp

 

Thanks

About Author

Author Image
Darshan Dang

Darshan is a creative UI designer with experience and capabilities to build compelling UI designs for Web and Mobile Applications. Darshan likes Punjabi songs and Travelling in Free Time .

Request for Proposal

Name is required

Comment is required

Sending message..