<div class="container">
  <div class="col">
    <img src="https://images.unsplash.com/photo-1605347220242-04d3b97ceee9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80" onClick="openLightbox(this)" />
  </div>
  <div class="col">
    <img src="https://images.unsplash.com/photo-1605306030698-6e966cc142b4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80" onClick="openLightbox(this)" />
  </div>
  <div class="col">
    <img src="https://images.unsplash.com/photo-1593642634402-b0eb5e2eebc9?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80" onClick="openLightbox(this)" />
  </div>
</div>
<div id="lightbox" class="lightbox hidden">
  <div onClick="closeLightbox()" class="close">❌</div>
  <div class="lightbox-content">
    <img id="lightbox-image" />
  </div>
</div>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.container {
  display: flex;
  flex-wrap: wrap;
  background: url("https://images.unsplash.com/photo-1558051815-0f18e64e6280?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1949&q=80")
    no-repeat center center;
  background-position: cover;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  .col {
    width: 30%;
    margin: 1.6%;
    img {
      cursor: pointer;
      border: 5px solid #fff;
      box-shadow: 0 0 1rem #aaaaaa;
      max-width: 100%;
      max-height: 100%;
    }
  }
}

.lightbox {
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
  opacity: 1;
  visibility: visible;
  transition: all 0.3s ease;
  &.hidden {
    opacity: 0;
    visibility: hidden;
  }
  .close {
    position: absolute;
    right: 2.5%;
    top: 2.5%;
    font-size: 2rem;
    cursor: pointer;
  }
  &-content {
    display: flex;
    margin: 5%;
    align-items: center;
    justify-content: center;
    img {
      max-width: 100%;
      max-height: 100%;
      border: 5px solid #fff;
    }
  }
}
View Compiled
const lightbox = document.getElementById("lightbox");
const lightboxHolder = document.getElementById("lightbox-image");

openLightbox = (element) => {
  lightboxHolder.src = element.src;  lightbox.classList.remove("hidden");
};

closeLightbox = () => lightbox.classList.add("hidden");

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.