Responsive Lightbox Slider with jQuery Featherlight Plugin

Responsive Lightbox Slider with jQuery Featherlight Plugin
Code Snippet:Featherlight
Author: noelboss
Published: January 20, 2024
Last Updated: January 22, 2024
Downloads: 4,071
License: MIT
Edit Code online: View on CodePen
Read More

The Featherlight is a lightweight jQuery lightbox plugin to show images, iframes, videos, and inline content. It is a simple yet flexible responsive lightbox slider built with jQuery and CSS. It creates a basic image gallery and loads the actual image when the user clicks on the image thumbnail.
The plugin provides classes for each element to customize with CSS styles. Also, you can fully configure it with its available options.

How to Create a jQuery Lightbox Slider

1. Load the jQuery and Featherlight‘s CSS and JavaScript files into your HTML document.

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- Featherlight CSS -->
<link type="text/css" rel="stylesheet" href="css/featherlight.css" />
<link type="text/css" rel="stylesheet" href="css/featherlight.gallery.css" />

<!-- Featherlight JS -->
<script src="js/featherlight.js" type="text/javascript" charset="utf-8"></script>
<script src="js/featherlight.gallery.js" type="text/javascript" charset="utf-8"></script>

2. After that, create a basic HTML structure for the image gallery and add your images.

<div class="container">
<div class="row">
   <div class="col-lg-2">
      <a class="thumbnail gallery" href="assets/images/droplets.jpg"><img src="assets/images/droplets.thumb.jpg" /></a>
   </div>
   <div class="col-lg-2">
      <a class="thumbnail gallery" href="assets/images/blue.jpg"><img src="assets/images/blue.thumb.jpg" /></a>
   </div>
   <div class="col-lg-2">
      <a class="thumbnail gallery" href="assets/images/feed.jpg"><img src="assets/images/feed.thumb.jpg" /></a>
   </div>
   <div class="col-lg-2">
      <a class="thumbnail gallery" href="assets/images/black.jpg"><img src="assets/images/black.thumb.jpg" /></a>
   </div>
   <div class="col-lg-2">
      <a class="thumbnail gallery" href="assets/images/red_and_yellow.jpg"><img src="assets/images/red_and_yellow.thumb.jpg" /></a>
   </div>
</div>

3. Finally, initialize the plugin in the jQuery document ready function with all default options to activate the lightbox slider.

$(document).ready(function(){

   $('.gallery').featherlightGallery();
					
});

Advanced Configuration Options

The following are some advanced configuration options to create/customize a “jQuery responsive lightbox slider”.

Option Description, Default, Type
openTrigger & closeTrigger These options define the event type on which the lightbox will open / close. Default: “click”, Type: String.

$('.gallery').featherlightGallery({
   openTrigger:    'click',
   closeTrigger:   'click', 
});
openSpeed & closeSpeed Define the transition duration in milliseconds for lightbox open & close. Default: 250, Type: Number.

$('.gallery').featherlightGallery({
   openSpeed: 250,
   closeSpeed: 250,
});
loading Content to show while initial content is loading. Default: ”, Type: String.

$('.gallery').featherlightGallery({
   loading: "",
});
closeOnClick Decide whether to close the lightbox on click anywhere. Default: ‘background’, Type: String / Bool.
false to disable.

$('.gallery').featherlightGallery({
   closeOnClick: false,
});

That’s all! hopefully, you have successfully created a responsive lightbox slider using jQuery. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X