glightbox is a modern, lightweight JavaScript library for creating responsive and interactive lightboxes for images, videos, and galleries. This section covers the steps required to include glightbox in your project:
To install glightbox, run the following command in the root directory of your project:
yarn add glightbox --save
To use glightbox in your project, you need to include its stylesheet and JavaScript files in your Laravel:
<link rel="stylesheet" href="assets/libs/glightbox/glightbox.css"><link/>
<script src="assets/libs/glightbox/js/glightbox.min.js"><script/>
Below is an example of the HTML code to create a gallery using glightbox. Each image is wrapped in an anchor `` tag, which triggers the lightbox when clicked:
<a href="assets/images/gallery/image-1.jpg" class="lightbox"> <img src="assets/images/gallery/image-1.jpg" class="img-fluid rounded-2" alt="gallery image"> </a><a href="assets/images/gallery/image-2.jpg" class="lightbox"> <img src="assets/images/gallery/image-2.jpg" class="img-fluid rounded-2" alt="gallery image"> </a>
Here is the JavaScript code that initializes the glightbox instance. This will enable the lightbox functionality for all elements with the class `.lightbox`:
let glightboxElement = document.getElementsByClassName('lightbox')[0]; if (glightboxElement) { var lightbox = GLightbox({ selector: '.lightbox', title: false, // Optional: Set to true if you want to display image titles in the lightbox }); }
The above JavaScript code does the following:
Be the first to know about new updates and exclusive discounts. No spam, just great offers!
How about
With over 7 years of experienced team, we specialize in delivering custom projects for startups, blue-chip companies, and government agencies. We have successfully completed over 250+ projects, providing tailored solutions that meet the unique needs of each client.
Support© Herozi Design & Develop by Codebucks.