Scroll · 29 of 34

Staggered List

List items slide and fade in one at a time, top to bottom. Uses nth-child transition delays, so adding items needs no extra code.

HTML · CSS · JavaScript · No dependencies · MIT

HTML

<section class="stagger-list-section">
  <ul class="stagger-list">
    <li>List Item 1</li>
    <li>List Item 2</li>
    <li>List Item 3</li>
    <li>List Item 4</li>
  </ul>
</section>

CSS

.stagger-list-section {
  min-height: 35vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f0f0f5;
}

.stagger-list {
  list-style: none;
  padding: 0;
}

.stagger-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.5s, transform 0.5s;
}

.stagger-list-section.in-view li {
  opacity: 1;
  transform: translateX(0);
}

.stagger-list-section.in-view li:nth-child(2) { transition-delay: 100ms; }
.stagger-list-section.in-view li:nth-child(3) { transition-delay: 200ms; }
.stagger-list-section.in-view li:nth-child(4) { transition-delay: 300ms; }

JavaScript

var section = document.querySelector('.stagger-list-section');

new IntersectionObserver(function (entries) {
  entries.forEach(function (entry) {
    entry.target.classList.toggle('in-view', entry.isIntersecting);
  });
}, { threshold: 0.25 }).observe(section);