Easy Responsive Gallery & Lightbox Plugin For jQuery
| File Size: | 3.84 KB |
|---|---|
| Views Total: | 2177 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
A simple, lightweight jQuery plugin for creating an image gallery where your users are able to click the thumbnail to view the large version in a responsive, navigatable lightbox popup.
How to use it:
1. Insert your images into a DIV container with the CSS class of 'gallery'.
<div class="gallery">
<a href="large-1.jpeg">
<img src="thumb-1.jpg" alt="Image #1">
</a>
<a href="large-2.jpeg">
<img src="thumb-2.jpg" alt="Image #2">
</a>
<a href="large-3.jpeg">
<img src="thumb-3.jpg" alt="Image #3">
</a>
...
</div>
2. Include jQuery library and the main JavaScript file lightbox.js at the bottom of the webpage.
<script src="//code.jquery.com/jquery.min.js"></script> <script src="lightbox.js"></script>
3. Initialize the gallery lightbox plugin on link click.
$('.gallery').on('click', 'a', function (e) {
e.preventDefault();
Lightbox.init($(this));
});
4. Apply your own CSS styles to the gallery lightbox.
/* Sample style for lightbox */
.lightbox {
position: fixed;
z-index: 999;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
background-color: rgba(0, 0, 0, 0.9);
background-repeat: no-repeat;
background-position: center;
background-size: 20px;
}
.lightbox-image {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -55%);
max-width: 95%;
max-height: 85%;
border: 5px solid #fff;
box-shadow: 0 0 50px #000;
}
.lightbox-controls {
position: absolute;
left: 50%;
bottom: 2px;
transform: translateX(-50%);
padding: 0 10px;
border-radius: 50px;
background: rgba(255, 255, 255, 0.1);
white-space: nowrap;
transition: 0.2s;
}
.lightbox-controls button {
margin: 0 4px;
padding: 0 4px;
border: 0;
background: none;
color: rgba(255, 255, 255, 0.8);
font-size: 40px;
cursor: pointer;
}
.lightbox-controls button:hover { text-shadow: 0 0 10px #fff; }
.lightbox-controls button:focus {
outline: none;
color: #fff;
}
@media (min-width: 1024px) {
.lightbox-controls { bottom: -50px; }
.lightbox:hover .lightbox-controls { bottom: 10px; }
}
This awesome jQuery plugin is developed by jacmgh. For more Advanced Usages, please check the demo page or visit the official website.











