Lightweight Image Gallery With Lightbox Popup – havLightbox

Category: Gallery , Javascript , Modal & Popup | April 16, 2024
Author:Havoc2
Views Total:107 views
Official Page:Go to website
Last Update:April 16, 2024
License:MIT

Preview:

Lightweight Image Gallery With Lightbox Popup – havLightbox

Description:

HavLightbox is a lightweight galley lightbox JavaScript plugin that allows you to create image galleries with a lightbox overlay.

Visitors can click on thumbnails to view larger versions of the images, and navigate through them using next/previous buttons or by clicking on thumbnails displayed at the bottom of the lightbox.

How to use it:

1. Download and add the minified JavaScript and CSS from the dist folder to your project.

<link rel="stylesheet" href="/dist/css/havlightbox.min.css">
<script src="/dist/js/havlightbox.min.js"></script>

2. Create a container with the class havlightbox-gallery and add your images inside it. Use the src attribute for the thumbnail image and the data-havlightbox-image attribute for the full-size image.

<div class="havlightbox-gallery">
  <img 
    class="havlightbox-thumbnail" 
    src="thumbnail-1.webp" 
    data-havlightbox-image="full-1.webp"
    alt="Image Alt 1" />
  <img 
    class="havlightbox-thumbnail" 
    src="thumbnail-2.webp" 
    data-havlightbox-image="full-2.webp"
    alt="Image Alt 2" />
  <img 
    class="havlightbox-thumbnail" 
    src="thumbnail-3.webp" 
    data-havlightbox-image="full-3.webp"
    alt="Image Alt 3" />
  ... more image here ...
</div>

3. Build the HTML for the lightbox itself. This includes elements for the image counter, close button, image container, caption, thumbnail selection, and navigation buttons.

<div id="havLightbox" class="havlightbox">
  <div id="havLightboxImageCounter" class="havlightbox-image-counter"></div>
  <span class="havlightbox-close">&times;</span>
  <div class="havlightbox-image-container">
    <img src="" alt="havLightbox Image" id="havLightboxImg">
    <div id="havLightboxCaption" class="havlightbox-caption"></div>
    <div id="havLightboxThumbnailSelection" class="havlightbox-thumbnail-selection"></div>
  </div>
  <button id="havLightboxPrevBtn" class="havlightbox-prev-button">&#10094;</button>
  <button id="havLightboxNextBtn" class="havlightbox-next-button">&#10095;</button>
</div>

You Might Be Interested In:


Leave a Reply