MediaWiki:Common.css: Difference between revisions

From ChimniWiki
Jump to navigation Jump to search
(Created page with "→‎CSS placed here will be applied to all skins: .hover-gallery { position: relative; overflow: hidden; display: inline-block; } .hover-gallery img { width: 100%; height: auto; display: block; transition: opacity 0.3s ease-in-out; } .hover-gallery .alt-image { position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; } .hover-gallery:hover .alt-image { opacity: 1; pointer-events: auto; }")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 11: Line 11:
   height: auto;
   height: auto;
   display: block;
   display: block;
  transition: opacity 0.3s ease-in-out;
}
}


/* MAIN IMAGE: Visible by default */
.hover-gallery .main-image {
  position: relative;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}
/* ALT IMAGES: Positioned above, hidden by default */
.hover-gallery .alt-image {
.hover-gallery .alt-image {
   position: absolute;
   position: absolute;
   top: 0;
   top: 0;
   left: 0;
   left: 0;
  width: 100%;
   opacity: 0;
   opacity: 0;
   pointer-events: none;
   pointer-events: none;
  z-index: 2;
  transition: opacity 0.5s ease-in-out;
  animation-duration: 6s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}
}


/* On hover: hide main image and start animation */
.hover-gallery:hover .main-image {
  opacity: 0;
}
/* On hover: activate animation on alt images */
.hover-gallery:hover .alt-image {
.hover-gallery:hover .alt-image {
   opacity: 1;
   animation-name: fadeCycle;
   pointer-events: auto;
}
 
/* Apply staggered delays to alternate images */
.hover-gallery .alt-image:nth-of-type(2) { animation-delay: 0s; }
.hover-gallery .alt-image:nth-of-type(3) { animation-delay: 2s; }
.hover-gallery .alt-image:nth-of-type(4) { animation-delay: 4s; }
 
/* Keyframes: show each image for 1.5s, fade in and out cleanly */
@keyframes fadeCycle {
  0% { opacity: 1; }
  25% { opacity: 1; }
  33% { opacity: 0; }
   100% { opacity: 0; }
}
 
/* ===== MOBILE FALLBACK: Always cycle alt images on mobile ===== */
@media (hover: none) and (pointer: coarse) {
  .hover-gallery .alt-image {
    animation-name: fadeCycle;
  }
 
  .hover-gallery .main-image {
    opacity: 0;
  }
}
 
 
/* Custom Flexbox Gallery */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: flex-start;
}
 
.gallery > * {
  flex: 0 1 300px; /* or adjust to match your template width */
}
}

Latest revision as of 12:25, 31 July 2025

/* CSS placed here will be applied to all skins */

.hover-gallery {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.hover-gallery img {
  width: 100%;
  height: auto;
  display: block;
}

/* MAIN IMAGE: Visible by default */
.hover-gallery .main-image {
  position: relative;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}

/* ALT IMAGES: Positioned above, hidden by default */
.hover-gallery .alt-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.5s ease-in-out;
  animation-duration: 6s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

/* On hover: hide main image and start animation */
.hover-gallery:hover .main-image {
  opacity: 0;
}

/* On hover: activate animation on alt images */
.hover-gallery:hover .alt-image {
  animation-name: fadeCycle;
}

/* Apply staggered delays to alternate images */
.hover-gallery .alt-image:nth-of-type(2) { animation-delay: 0s; }
.hover-gallery .alt-image:nth-of-type(3) { animation-delay: 2s; }
.hover-gallery .alt-image:nth-of-type(4) { animation-delay: 4s; }

/* Keyframes: show each image for 1.5s, fade in and out cleanly */
@keyframes fadeCycle {
  0% { opacity: 1; }
  25% { opacity: 1; }
  33% { opacity: 0; }
  100% { opacity: 0; }
}

/* ===== MOBILE FALLBACK: Always cycle alt images on mobile ===== */
@media (hover: none) and (pointer: coarse) {
  .hover-gallery .alt-image {
    animation-name: fadeCycle;
  }

  .hover-gallery .main-image {
    opacity: 0;
  }
}


/* Custom Flexbox Gallery */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: flex-start;
}

.gallery > * {
  flex: 0 1 300px; /* or adjust to match your template width */
}