Skip to content

noyaljoy/snapGallery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

261 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snapGallery.js

Create responsive galleries with minimal effort

snapGallery is a super-simple jQuery plugin that converts your unordered, haphazard, differently sized images into a beautiful gallery.

Completely responsive and customizable, snapGallery allows you to select the spacing between images, the minimum width allowed before stacking and the maximum number of columns, with more options on the way!

Download

Recommended: Download the script from here

Not recommended: link to the script

<script src="http://neerajdelima.ga/snapGallery/snapGallery.js"></script>

Usage

Add the following barebones HTML markup:

<ul id="gallery-container">
  <li><img src="./path/to/img1.jpg" /></li>
  <li><img src="./path/to/img2.jpg" /></li>
  <li><img src="./path/to/img3.jpg" /></li>
  <!-- -->
  <!-- -->
  <li><img src="./path/to/img21.jpg" /></li>
  <li><img src="./path/to/img22.jpg" /></li>
</ul>

Make sure to include both jQuery as well as the snapGallery script:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="./snapGallery.js"></script>

Call the plugin & watch the magic happen!

$(function() {
	$(window).load(function() {
		$('#gallery-container').snapGallery();
	});
})

You can also provide parameters to customize the layout to your needs:

$(function() {
	$(window).load(function() {
		$('#gallery-container').snapGallery({
			minWidth: 100,
			maxCols: 4,
			margin: 7
		});
	});
})

Demo

snapGallery takes an unordered list of images like this:

Snap Gallery Before image

and converts them into a gallery like this:

Snap Gallery After image

About

A simple jQuery plugin that allows you to create good looking image galleries with zero effort.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • HTML 43.3%
  • CSS 37.2%
  • JavaScript 19.5%