Simplest Image & Video Lightbox Plugin - JS Lightbox

File Size: 8.3 KB
Views Total: 4327
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Simplest Image & Video Lightbox Plugin - JS Lightbox

A really small and simple jQuery based lightbox library used to overlay any image or HTML5 video on top of the current page.

The users are able to close the lightbox by clicking outside of the image or video.

How to use it:

1. Load the lightbox.min.css for the basic styling of the lightbox.

<link href="css/lightbox.min.css" rel="stylesheet">

2. Load jQuery library and the lightbox.min.js right before the closing body tag.

<script src="" 
<script src="js/lightbox.js"></script>

3. Apply the lightbox to a given image within the document.

<img src="" class="lightbox-img">

4. Apply the lightbox to a given HTML5 video within the document. The plugin also adds the autoplay webkit-playsinline loop attributes to your video tag.

<video width="400" controls class="lightbox-vid">
  <source src="" type="video/mp4">
  <source src="" type="video/ogg">
  Your browser does not support HTML5 video.

5. Override the default styles of the lightbox background/content.

/* Lightbox Background */
#lightbox-display {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 100; /* Sit on top */
  /*padding-top: 4em; *//* Location of the box */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.9); /* Black w/ opacity */

/* Lightbox Content */
#lightbox-content {
  position: absolute;
  margin: auto;
  display: block;
  max-height: 95vh;
  max-width: 95vw;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 1px;

This awesome jQuery plugin is developed by mfappsandweb. For more Advanced Usages, please check the demo page or visit the official website.