Scroll · 22 of 34
Sticky Stack
Cards pin to the viewport and stack on top of each other as you scroll through the section. Built on position: sticky with a rotation and offset per card.
This one is driven by scroll position, so it reads best in context. See it on the scroll page.
<section class="sticky-stack-section">
<div class="stack-card stack-card-1">Card 1</div>
<div class="stack-card stack-card-2">Card 2</div>
<div class="stack-card stack-card-3">Card 3</div>
</section>
.sticky-stack-section {
height: 60vh;
position: relative;
display: flex;
align-items: center;
justify-content: center;
perspective: 1000px;
color: #f0f0f5;
}
.stack-card {
position: absolute;
width: 200px;
height: 120px;
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transform: translateY(100px) scale(0.8);
transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s;
}
.stack-card-1 { z-index: 1; background: #222; }
.stack-card-2 { z-index: 2; background: #333; }
.stack-card-3 { z-index: 3; background: #444; }
/* Cards settle into a fanned stack, each slightly delayed */
.sticky-stack-section.in-view .stack-card-1 {
opacity: 1;
transform: translateY(-40px) scale(0.9);
}
.sticky-stack-section.in-view .stack-card-2 {
opacity: 1;
transform: translateY(-20px) scale(0.95);
transition-delay: 0.1s;
}
.sticky-stack-section.in-view .stack-card-3 {
opacity: 1;
transform: translateY(0) scale(1);
transition-delay: 0.2s;
}
var section = document.querySelector('.sticky-stack-section');
new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
entry.target.classList.toggle('in-view', entry.isIntersecting);
});
}, { threshold: 0.25 }).observe(section);