Gallery · 32 of 33

Chromatic Aberration

RGB channels split apart on hover

HTML · CSS · No dependencies · MIT

HTML

<div class="chroma-split">
  <img src="https://picsum.photos/id/225/800/600" alt="Chroma" class="chroma-base">
  <img src="https://picsum.photos/id/225/800/600" alt="" aria-hidden="true" class="chroma-r">
  <img src="https://picsum.photos/id/225/800/600" alt="" aria-hidden="true" class="chroma-b">
</div>

CSS

.chroma-split {
  position: relative;
  width: 400px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
}

.chroma-split img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s;
}

/* Two tinted ghost copies that slide apart on hover */
.chroma-r,
.chroma-b {
  position: absolute;
  top: 0; left: 0;
  opacity: 0;
  mix-blend-mode: screen;
  pointer-events: none;
}

.chroma-r { filter: sepia(1) saturate(6) hue-rotate(-50deg); }
.chroma-b { filter: sepia(1) saturate(6) hue-rotate(180deg); }

.chroma-split:hover .chroma-r {
  opacity: 0.55;
  transform: translate(-8px, 3px);
}

.chroma-split:hover .chroma-b {
  opacity: 0.55;
  transform: translate(8px, -3px);
}