Patterns Medium
Clip-Path Lightbox Expand
Gallery lightbox that expands from the clicked card's exact position using GSAP clip-path animation. Computes inset() coordinates from getBoundingClientRect, animates to fullscreen and back. Full keyboard navigation.
gsapclip-pathlightboxkeyboard-navscrolltrigger
Targets: JS HTML
Code
/* ── Demo 51: Clip-Path Lightbox ── */
/* Muted dark green/navy with vibrant card accents */
:root {
--bg: #0a0c10;
--panel: #121620;
--border: #1e2430;
--text: #e8eaf0;
--muted: #6870888;
--muted: #687088;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
-webkit-font-smoothing: antialiased;
overflow-x: hidden;
}
.label {
display: block;
font-size: 0.65rem;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 0.75rem;
}
/* ── Page layout ── */
.page {
max-width: 1200px;
margin: 0 auto;
padding: 5rem 2.5rem 8rem;
}
.page-header {
margin-bottom: 4rem;
}
.page-header h1 {
font-family: 'Syne', sans-serif;
font-size: clamp(3rem, 8vw, 6rem);
font-weight: 800;
line-height: 1.0;
letter-spacing: -0.03em;
margin-bottom: 1.5rem;
color: var(--text);
}
.page-header h1 em {
font-style: normal;
color: transparent;
-webkit-text-stroke: 1px rgba(255,255,255,0.4);
}
.page-header p {
font-size: 0.95rem;
color: var(--muted);
line-height: 1.8;
max-width: 480px;
}
.page-header code {
font-family: 'SF Mono', monospace;
font-size: 0.8rem;
color: #60c8ff;
background: rgba(96, 200, 255, 0.1);
padding: 0.1em 0.4em;
border-radius: 3px;
}
/* ── Gallery ── */
.gallery-section { }
.gallery-label { margin-bottom: 1.5rem; }
.gallery-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: auto;
gap: 12px;
}
/* ── Gallery cards ── */
.gallery-card {
position: relative;
aspect-ratio: 3/4;
border-radius: 4px;
overflow: hidden;
cursor: pointer;
background: var(--panel);
border: 1px solid var(--border);
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gallery-card--wide {
grid-column: span 2;
aspect-ratio: 16/9;
}
.gallery-card:hover {
transform: scale(1.02);
z-index: 2;
}
/* Card art backgrounds */
.gc-art {
position: absolute;
inset: 0;
transition: transform 0.5s ease;
}
.gallery-card:hover .gc-art {
transform: scale(1.06);
}
.gc-art--1 {
background:
radial-gradient(ellipse at 40% 30%, rgba(160, 60, 255, 0.5) 0%, transparent 55%),
radial-gradient(ellipse at 70% 70%, rgba(0, 180, 255, 0.3) 0%, transparent 45%),
linear-gradient(160deg, #1a0a2e 0%, #0a0418 100%);
}
.gc-art--2 {
background:
radial-gradient(ellipse at 50% 60%, rgba(40, 200, 80, 0.4) 0%, transparent 60%),
radial-gradient(ellipse at 80% 20%, rgba(20, 140, 60, 0.2) 0%, transparent 40%),
linear-gradient(160deg, #0a1a10 0%, #040c08 100%);
}
.gc-art--3 {
background:
radial-gradient(ellipse at 60% 40%, rgba(255, 140, 30, 0.5) 0%, transparent 55%),
radial-gradient(ellipse at 20% 80%, rgba(200, 80, 0, 0.3) 0%, transparent 45%),
linear-gradient(160deg, #1a0e00 0%, #0c0600 100%);
}
.gc-art--4 {
background:
radial-gradient(ellipse at 30% 50%, rgba(0, 180, 255, 0.35) 0%, transparent 65%),
radial-gradient(ellipse at 80% 30%, rgba(0, 100, 220, 0.25) 0%, transparent 50%),
linear-gradient(160deg, #001018 0%, #000c14 100%);
}
.gc-art--5 {
background:
radial-gradient(ellipse at 50% 40%, rgba(255, 30, 80, 0.45) 0%, transparent 55%),
radial-gradient(ellipse at 20% 70%, rgba(180, 0, 120, 0.25) 0%, transparent 45%),
linear-gradient(160deg, #18000a 0%, #0e0004 100%);
}
.gc-info {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 1.5rem 1.25rem 1.25rem;
background: linear-gradient(transparent, rgba(0,0,0,0.8));
}
.gc-info h3 {
font-family: 'Syne', sans-serif;
font-size: 1rem;
font-weight: 700;
color: var(--text);
margin-bottom: 0.2rem;
}
.gc-info span {
font-size: 0.72rem;
color: rgba(255,255,255,0.5);
letter-spacing: 0.06em;
}
.gc-expand-hint {
position: absolute;
top: 1rem;
right: 1rem;
width: 32px;
height: 32px;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.8rem;
color: rgba(255,255,255,0.5);
opacity: 0;
transition: opacity 0.2s, background 0.2s;
}
.gallery-card:hover .gc-expand-hint {
opacity: 1;
background: rgba(255,255,255,0.1);
}
/* ── Lightbox ── */
.lightbox {
position: fixed;
inset: 0;
z-index: 500;
background: #060810;
display: grid;
grid-template-columns: 1fr 380px;
/* clip-path starts as an inset rectangle matching the clicked card */
clip-path: inset(0 0 0 0 round 4px);
}
.lightbox[hidden] {
display: none;
}
.lb-art {
height: 100%;
position: relative;
overflow: hidden;
}
.lb-content {
padding: 3rem 2.5rem;
display: flex;
flex-direction: column;
justify-content: center;
border-left: 1px solid var(--border);
overflow: auto;
}
.lb-meta {
margin-bottom: 1.5rem;
}
.lb-title {
font-family: 'Syne', sans-serif;
font-size: 2.5rem;
font-weight: 800;
letter-spacing: -0.02em;
color: var(--text);
margin-bottom: 0.4rem;
line-height: 1.1;
}
.lb-sub {
font-size: 0.8rem;
font-weight: 500;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--muted);
}
.lb-body {
font-size: 0.95rem;
color: rgba(232, 234, 240, 0.7);
line-height: 1.85;
margin-bottom: 2.5rem;
}
.lb-close {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
background: transparent;
border: 1px solid var(--border);
color: var(--muted);
font-family: 'Inter', sans-serif;
font-size: 0.8rem;
font-weight: 500;
letter-spacing: 0.06em;
cursor: pointer;
border-radius: 2px;
align-self: flex-start;
transition: border-color 0.2s, color 0.2s;
}
.lb-close:hover {
border-color: rgba(255,255,255,0.3);
color: var(--text);
}
/* Nav buttons */
.lb-nav {
position: absolute;
bottom: 2rem;
left: 2rem;
display: flex;
gap: 0.5rem;
}
.lb-prev, .lb-next {
width: 44px;
height: 44px;
border: 1px solid var(--border);
background: rgba(0,0,0,0.5);
color: var(--text);
font-size: 1rem;
cursor: pointer;
border-radius: 2px;
display: flex;
align-items: center;
justify-content: center;
transition: border-color 0.2s, background 0.2s;
}
.lb-prev:hover, .lb-next:hover {
border-color: rgba(255,255,255,0.4);
background: rgba(255,255,255,0.05);
}
/* ── Responsive ── */
@media (max-width: 900px) {
.gallery-grid { grid-template-columns: 1fr 1fr; }
.gallery-card--wide { grid-column: span 2; }
.lightbox { grid-template-columns: 1fr; }
.lb-content { border-left: none; border-top: 1px solid var(--border); max-height: 40vh; }
}
@media (max-width: 600px) {
.gallery-grid { grid-template-columns: 1fr; }
.gallery-card--wide { grid-column: auto; aspect-ratio: 3/4; }
.page { padding: 3rem 1.25rem 5rem; }
}
/* ── Reduced motion ── */
html.reduced-motion .gallery-card {
transition: none;
}
html.reduced-motion .gc-art {
transition: none;
}Clip-Path Lightbox Expand
Gallery lightbox that expands from the clicked card’s exact position using GSAP clip-path animation. Computes inset() coordinates from getBoundingClientRect, animates to fullscreen and back. Full keyboard navigation.
Source
- Repository:
libs-genclaude - Original demo id:
51-clip-path-lightbox
Notes
Gallery lightbox that expands from the clicked card’s exact position using GSAP clip-path animation. Computes inset() coordinates from getBoundingClientRect, animates to fullscreen and back. Full keyboard navigation.