"masonry Image Gallery"
Bootstrap 3.3.0 Snippet by Sagar Joshi

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <h1>Masonry + imagesLoaded, iteratively reveal items</h1> <div id="container"></div> <div id="images"> <div class="item"> <img src="https://picsum.photos/100/200?random=1"> </div> <div class="item"> <img src="https://picsum.photos/200/300?random=2"> </div> <div class="item"> <img src="https://picsum.photos/300/400?random=3"> </div> <div class="item"> <img src="https://picsum.photos/200/100?random=4"> </div> <div class="item"> <img src="https://picsum.photos/300/200?random=5"> </div> <div class="item"> <img src="https://picsum.photos/400/300?random=6"> </div> <div class="item"> <img src="https://picsum.photos/500/500?random=7"> </div> <div class="item"> <img src="https://picsum.photos/500/600?random=8"> </div> <div class="item"> <img src="https://picsum.photos/100/300?random=9"> </div> <div class="item"> <img src="https://picsum.photos/250/300?random=10"> </div> <div class="item"> <img src="https://picsum.photos/100/200?random=11"> </div> <div class="item"> <img src="https://picsum.photos/200/300?random=12"> </div> <div class="item"> <img src="https://picsum.photos/300/400?random=13"> </div> <div class="item"> <img src="https://picsum.photos/200/100?random=14"> </div> <div class="item"> <img src="https://picsum.photos/300/200?random=15"> </div> <div class="item"> <img src="https://picsum.photos/400/300?random=16"> </div> <div class="item"> <img src="https://picsum.photos/500/500?random=17"> </div> <div class="item"> <img src="https://picsum.photos/500/600?random=18"> </div> <div class="item"> <img src="https://picsum.photos/100/300?random=19"> </div> <div class="item"> <img src="https://picsum.photos/250/300?random=110"> </div> </div> <p> <button id="load-images">Load images</button> <script src="//masonry.desandro.com/masonry.pkgd.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.js"></script> </div> </p>
body { font-family: sans-serif; } #container { background: #DDD; max-width: 1200px; } .item { width: 200px; float: left; } .item img { display: block; width: 100%; } button { font-size: 18px; } .container{ width:100%; }
$(function () { var $container = $('#container').masonry({ itemSelector: '.item', columnWidth: 200 }); // reveal initial images $container.masonryImagesReveal($('#images').find('.item')); }); $.fn.masonryImagesReveal = function ($items) { var msnry = this.data('masonry'); var itemSelector = msnry.options.itemSelector; // hide by default $items.hide(); // append to container this.append($items); $items.imagesLoaded().progress(function (imgLoad, image) { // get item // image is imagesLoaded class, not <img>, <img> is image.img var $item = $(image.img).parents(itemSelector); // un-hide item $item.show(); // masonry does its thing msnry.appended($item); }); return this; };

Related: See More


Questions / Comments:

How to add zoom like lightbox after click?

Michał Skrobek () - 7 years ago - Reply 0


nhghh

Pham Duyen () - 7 years ago - Reply 0


We are stonemasons from Edinburgh

drskoczy () - 8 years ago - Reply 0