Skip to main content
InterviewHubPRO
Section Overview
Q42

Question 42 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

84%
CSS3 & Modern Layouts (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

CSS Scroll-Driven Animations: `animation-timeline: scroll()`.

senior LevelCode ExampleSystem Design

In Simple Words: Scroll-driven animations link keyframe progress to a scroll container or element visibility rather than wall-clock time, running on the browser's compositor thread with zero JavaScript:

  • animation-timeline: scroll(): Tracks scroll position of the viewport or parent.
  • animation-timeline: view(): Tracks when an element enters and exits the viewport.
css
/* Reading progress bar that fills as the user scrolls */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 100%;
  transform-origin: 0 50%;
  animation: scale-x linear;
  animation-timeline: scroll();
}

@keyframes scale-x {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}