LICENSE
4 years ago
README.md
4 years ago
masonry.pkgd.js
6 years ago
masonry.pkgd.min.js
6 years ago
README.md
85 lines
| 1 | # Masonry |
| 2 | |
| 3 | _Cascading grid layout library_ |
| 4 | |
| 5 | Masonry works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall. You’ve probably seen it in use all over the Internet. |
| 6 | |
| 7 | See [](https://masonry.desandro.commasonry.desandro.com](https://masonry.desandro.com](https://masonry.desandro.com) for complete docs and demos. |
| 8 | |
| 9 | ## Install |
| 10 | |
| 11 | ### Download |
| 12 | |
| 13 | + [](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.jsmasonry.pkgd.js](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.js](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.js) un-minified, or |
| 14 | + [](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.jsmasonry.pkgd.min.js](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js](https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js) minified |
| 15 | |
| 16 | ### CDN |
| 17 | |
| 18 | Link directly to Masonry files on [](https://unpkg.com/unpkg](https://unpkg.com/](https://unpkg.com/). |
| 19 | |
| 20 | ``` html |
| 21 | <script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.js"></script> |
| 22 | <!-- or --> |
| 23 | <script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script> |
| 24 | ``` |
| 25 | |
| 26 | ### Package managers |
| 27 | |
| 28 | [](https://www.npmjs.com/package/masonry-layoutnpm](https://www.npmjs.com/package/masonry-layout](https://www.npmjs.com/package/masonry-layout): `npm install masonry-layout --save` |
| 29 | |
| 30 | Bower: `bower install masonry-layout --save` |
| 31 | |
| 32 | ## Support Masonry development |
| 33 | |
| 34 | Masonry has been actively maintained and improved upon for 8 years, with 900 GitHub issues closed. Please consider supporting its development by [](https://metafizzy.copurchasing a license for one of Metafizzy's commercial libraries](https://metafizzy.co](https://metafizzy.co). |
| 35 | |
| 36 | ## Initialize |
| 37 | |
| 38 | With jQuery |
| 39 | |
| 40 | ``` js |
| 41 | $('.grid').masonry({ |
| 42 | // options... |
| 43 | itemSelector: '.grid-item', |
| 44 | columnWidth: 200 |
| 45 | }); |
| 46 | ``` |
| 47 | |
| 48 | With vanilla JavaScript |
| 49 | |
| 50 | ``` js |
| 51 | // vanilla JS |
| 52 | // init with element |
| 53 | var grid = document.querySelector('.grid'); |
| 54 | var msnry = new Masonry( grid, { |
| 55 | // options... |
| 56 | itemSelector: '.grid-item', |
| 57 | columnWidth: 200 |
| 58 | }); |
| 59 | |
| 60 | // init with selector |
| 61 | var msnry = new Masonry( '.grid', { |
| 62 | // options... |
| 63 | }); |
| 64 | ``` |
| 65 | |
| 66 | With HTML |
| 67 | |
| 68 | Add a `data-masonry` attribute to your element. Options can be set in JSON in the value. |
| 69 | |
| 70 | ``` html |
| 71 | <div class="grid" data-masonry='{ "itemSelector": ".grid-item", "columnWidth": 200 }'> |
| 72 | <div class="grid-item"></div> |
| 73 | <div class="grid-item"></div> |
| 74 | ... |
| 75 | </div> |
| 76 | ``` |
| 77 | |
| 78 | ## License |
| 79 | |
| 80 | Masonry is released under the [](http://desandro.mit-license.orgMIT license](http://desandro.mit-license.org](http://desandro.mit-license.org). Have at it. |
| 81 | |
| 82 | * * * |
| 83 | |
| 84 | Made by David DeSandro |
| 85 |