Sticky-stack kaarten
Cards pin and scale down as the next slides over.
A
B
C
How to use it
- Paste the HTML where the scroll effects should appear. Include the script tags at the top once per page.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Sticky-stack kaarten · NedDev · eigen werk. -->
<!-- benodigd, één keer per pagina: -->
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<div class="jouw-container">
<div class="sstack-root"><div class="sstack-card" style="--i:0">A</div><div class="sstack-card" style="--i:1">B</div><div class="sstack-card" style="--i:2">C</div></div>
</div>/* Sticky-stack kaarten · NedDev · eigen werk. */
.sstack-root{position:absolute;inset:0;overflow:hidden;background:#0e0e14}
.sstack-card{position:absolute;inset:14px;display:flex;align-items:center;justify-content:center;font:60px 'Boldonse','Switzer',sans-serif;color:#fff;border-radius:10px;will-change:transform}
.sstack-card[style*="--i:0"]{background:#1a1a1a;z-index:1}.sstack-card[style*="--i:1"]{background:#F5480F;z-index:2;transform:translateY(40%)}.sstack-card[style*="--i:2"]{background:#2a2a2a;z-index:3;transform:translateY(80%)}// Sticky-stack kaarten · NedDev · eigen werk.
// root = het element waarin de HTML staat
function init(root){
if(!window.gsap)return;root.querySelectorAll('.sstack-card').forEach(function(c){gsap.to(c,{yPercent:0,ease:'none',scrollTrigger:{trigger:root,start:'top 85%',end:'bottom 45%',scrub:1}});});
}
init(document.querySelector('.jouw-container'));
More scroll effects
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →