StealThis .dev

Image Gallery Transitions

Thumbnail strip with hero image swap animated by View Transitions crossfade and scale.

Open in Lab
view-transitions-apicrossfade
Targets: JS HTML

Code

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root { --bg: #070a12; --text: #f0f4fb; --muted: #8a95a8; --accent: #86e8ff; --border: #263249; }

body { background: var(--bg); color: var(--text); font-family: 'Inter', 'SF Pro Display', system-ui, sans-serif; min-height: 100vh; }

.header { text-align: center; padding: 5rem 2rem 2rem; }
.eyebrow { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent); margin-bottom: 1rem; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -0.02em; }
.subtitle { font-size: clamp(0.9rem, 2vw, 1.05rem); color: var(--muted); max-width: 460px; margin: 0.75rem auto 0; line-height: 1.6; }

/* Gallery */
.gallery { max-width: 900px; margin: 0 auto; padding: 0 2rem; }

.hero-area { margin-bottom: 1.5rem; }

.hero-image {
  width: 100%; aspect-ratio: 16/9; border-radius: 18px;
  background: linear-gradient(135deg, hsl(var(--hue,200) 50% 12%), hsl(var(--hue,200) 65% 22%), hsl(calc(var(--hue,200) + 50) 50% 18%));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

.hero-number {
  font-size: 6rem; font-weight: 700; color: rgba(255,255,255,0.06); line-height: 1;
}

.hero-label {
  font-size: 1.1rem; font-weight: 600; color: rgba(255,255,255,0.7);
  margin-top: -0.5rem;
}

/* Thumbnails */
.thumb-strip {
  display: flex; gap: 0.6rem; overflow-x: auto;
  padding: 0.5rem 0 1.5rem; scroll-snap-type: x mandatory;
  -ms-overflow-style: none; scrollbar-width: none;
}
.thumb-strip::-webkit-scrollbar { display: none; }

.thumb {
  flex-shrink: 0; width: 100px; height: 70px; border-radius: 10px;
  background: linear-gradient(135deg, hsl(var(--hue,200) 40% 12%), hsl(var(--hue,200) 55% 20%));
  border: 2px solid transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font: 700 1.2rem/1 'Inter', system-ui, sans-serif;
  color: rgba(255,255,255,0.15);
  transition: border-color 0.25s, transform 0.25s;
  scroll-snap-align: center;
}
.thumb:hover { border-color: rgba(134,232,255,0.3); transform: translateY(-2px); }
.thumb.active { border-color: var(--accent); box-shadow: 0 0 16px rgba(134,232,255,0.15); }

/* View Transitions */
::view-transition-old(hero-img) { animation: hero-out 0.3s ease-in; }
::view-transition-new(hero-img) { animation: hero-in 0.35s ease-out; }

@keyframes hero-out { to { opacity: 0; transform: scale(0.96); } }
@keyframes hero-in { from { opacity: 0; transform: scale(1.04); } }

.footer { text-align: center; padding: 1.5rem 2rem 3rem; }
.btn-back {
  display: inline-block; padding: 0.7rem 2rem; border-radius: 999px;
  border: 1px solid rgba(134,232,255,0.3); color: var(--accent); text-decoration: none;
  font: 600 0.85rem/1 'Inter', system-ui, sans-serif; transition: all 0.25s;
}
.btn-back:hover { background: rgba(134,232,255,0.08); border-color: var(--accent); }

@media (max-width: 640px) {
  .thumb { width: 80px; height: 56px; }
  .gallery { padding: 0 1rem; }
}

Thumbnail strip with hero image swap animated by View Transitions crossfade and scale.

Source

  • Repository: libs-genclaude
  • Original demo id: 14-image-gallery-vt

Notes

Thumbnail strip with hero image swap animated by View Transitions crossfade and scale.