Scroll-reveal cards

Putcode·10 hours ago
body {
  margin: 0;
  background: #0d0e12;
  color: #eceef2;
  font: 15px/1.5 system-ui, sans-serif;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 30vh;
}

.page__head {
  margin-bottom: 28px;
  text-align: center;
}

.page__head h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.page__head p {
  margin: 8px 0 0;
  color: #8f929d;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.card {
  padding: 20px;
  border: 1px solid #24262d;
  border-radius: 16px;
  background: linear-gradient(180deg, #17181e, #131418);
}

.card__num {
  color: #7c6cff;
  font: 600 0.8rem ui-monospace, monospace;
}

.card h2 {
  margin: 10px 0 6px;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: #a3a6b1;
  font-size: 0.9rem;
}

@supports (animation-timeline: view()) {
  .card {
    animation: reveal linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 30%;
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(40px) scale(0.96);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}

How to use it

Each card runs its own view() timeline, and animation-range controls when it starts and finishes. Browsers without scroll-driven animations show the cards normally, because the animation only exists inside @supports.