Skip to main content

CSS: Image Popup and Lightbox

<style>
/* ========================================
   LIGHTBOX & IMAGE POPUP - Core Transition Class
   Applies smooth 1s transitions to all animated elements
   ======================================== */
.trans,
.lightbox,
.lightbox img {
  transition: all 1s ease;
  -moz-transition: all 1s ease;
  -ms-transition: all 1s ease;
  -o-transition: all 1s ease;
  -webkit-transition: all 1s ease;
}

/* Extended 1.2s fade-in for lightbox activation */
.lightbox:target,
.lightbox:target img {
  transition: all 1.2s ease;
  -moz-transition: all 1.2s ease;
  -ms-transition: all 1.2s ease;
  -o-transition: all 1.2s ease;
  -webkit-transition: all 1.2s ease;
}

/* ========================================
   IMGPOP - Thumbnail Container in Table
   Simple flex wrapper; click to enlarge
   ======================================== */
.imgpop {
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Image inside thumbnail */
.imgpop img {
  display: block;
  width: 100% !important;
  height: auto !important;
  min-height: 180px !important;   
  object-fit: contain;
  max-width: 100% !important;
}
/* Optional: Dark overlay on hover (from original) */
.imgpop::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(5, 5, 5, .4);
  opacity: 0.4;
  pointer-events: none;
  transition: all 0.5s ease;
  -moz-transition: all 0.5s ease;
  -ms-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  -webkit-transition: all 0.5s ease;
  z-index: 1;
}

.imgpop:hover::before {
  opacity: 0;
  background-color: rgba(0, 0, 0, 0.90);
}
/* MOBILE: Force full-width images in ALL tables with .imgpop */
@media (max-width: 768px) {
  .imgpop img {
    width: 100% !important;
    height: auto !important;
  }
  /* Optional: reduce cell padding on mobile for tighter fit */
  table td .imgpop {
    padding: 2px;
  }
}

/* ========================================
   LIGHTBOX - Fullscreen Image Viewer
   Activated via :target (hash links like #001)
   ======================================== */
.lightbox {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .75);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  text-align: center;
}

/* Image starts off-screen */
.lightbox img {
  max-width: 90%;
  max-height: 80%;
  position: relative;
  top: -100%;
  z-index: 9999;
}

/* Lightbox active state */
.lightbox:target {
  outline: none;
  top: 0;
  opacity: 1;
  pointer-events: auto;
}

/* Center image vertically */
.lightbox:target img {
  top: 50%;
  transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
  -webkit-transform: translateY(-50%);
}
</style>