Lightbox Gallery Made With Vanilla JS Using Babel/Gulp

lightbox-vanilla is a simplified javascript gallery to display all your images in a popup where users can navigate through the images using the arrows.

How to make use of it:

1. Add thumbnails to the gallery container.

<div class="gallery-container" id="gallery-container">
  <div class="gallery-item">
    <img class="gallery-img" src="1-thumb.jpg" alt="Descripcion 1">
  </div>
  <div class="gallery-item">
    <img class="gallery-img" src="2-thumb.jpg" alt="Descripcion 2">
  </div>
  <div class="gallery-item">
    <img class="gallery-img" src="3-thumb.jpg" alt="Descripcion 3">
  </div>
  ...
</div>

2. Load the main JavaScript file “lightbox.js” at the end of the document.

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

3. Basic CSS styles for gallery and popup.

.gallery-container {
  width: 900px;
  margin-left: auto;
  margin-right: auto;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns:(1fr)[4];
  grid-template-columns: repeat(4, 1fr);
  grid-gap: .5em
}
.gallery-img {
  display: block;
  max-width: 100%;
  cursor: pointer
}
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.8);
  display: -ms-flexbox;
  display: flex;
  z-index: 1
}
.lightbox-container {
  position: relative;
  margin: auto;
  background: #fff;
  padding: 1em;
  border-radius: .2em
}
.close-modal {
  background: tomato;
  color: #fff;
  position: absolute;
  width: 1.8em;
  height: 1.8em;
  text-align: center;
  line-height: 1.8em;
  top: -.9em;
  right: -.9em;
  border-radius: 50%;
  cursor: pointer
}
.lightbox-description {
  text-align: center;
  font-size: 1.1em
}
.lightbox-navigation {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: justify;
  justify-content: space-between;
  font-size: .9em;
  opacity: .8
}
.lightbox-navigation__button {
  text-decoration: none;
  color: tomato
}

lightbox gallery vanilla js plugin/github


See Demo And Download

Official Website(osanchezdev): Click Here

This superior jQuery/javascript plugin is developed by osanchezdev. For extra advanced usage, please go to the official website.

Share