Incredible scroll-based animations with CSS-only

Kevin Powell

Kevin Powell

32 min, 23 sec

A guide to creating scroll-linked animations using only CSS.

Summary

  • Introduction to creating animations that are linked to the user's scroll position without using JavaScript.
  • Demonstration of a scroll watcher to highlight scroll listeners' functionality.
  • Explanation of animation timelines with respect to scrolling and how they can be modified.
  • Discussion on browser support for scroll timelines and how to use a polyfill as a fallback.

Chapter 1

Introduction to Scroll-Linked Animations

0:00 - 28 sec

An introduction to scroll-linked animations and what will be covered in the video.

An introduction to scroll-linked animations and what will be covered in the video.

  • An overview of scroll-based animations and the types of effects achievable.
  • Mention that creating such animations can be done without writing JavaScript or using third-party plugins.

Chapter 2

Building Scroll Watchers

0:27 - 3 min, 24 sec

Creating a basic scroll watcher animation to understand scroll listeners.

Creating a basic scroll watcher animation to understand scroll listeners.

  • Creation of a fixed-position scroll watcher bar that scales horizontally as the user scrolls.
  • Usage of the 'scale' property in keyframe animations to manipulate the scroll watcher's width.
  • Adjusting the transform origin to control the direction of the scroll watcher's growth.
  • Correction of a mistakenly used 'animation' keyword when 'keyframes' was intended.

Chapter 3

Animating Images on Scroll

3:52 - 9 min, 4 sec

Implementing animations that fade images in and out based on scroll position.

Implementing animations that fade images in and out based on scroll position.

  • Introduction to the 'animation timeline' property and how it relates to scrolling.
  • Customizing the start and end points of the animation using offsets and specifying the scroll axis.
  • Explanation of additional keywords like 'block' and 'inline' for specifying scroll directions.
  • Adjusting the animation with 'contain' and 'cover' to determine when the animation should start and end.

Chapter 4

Horizontal Scroll Animation

12:55 - 7 min, 55 sec

Creating an animation that responds to horizontal scrolling.

Creating an animation that responds to horizontal scrolling.

  • Switching the animation timeline to 'scroll' to target the nearest ancestor with a scrollbar.
  • Explanation of how the 'scroll' function changes context based on the nearest scrolling ancestor.
  • Demonstration of how to target scrolling on the root element to create an animation that responds to vertical page scrolling.

Chapter 5

Complex Scroll-Linked Animation

20:51 - 11 min, 33 sec

Combining techniques to create a complex scroll-linked animation with multiple elements.

Combining techniques to create a complex scroll-linked animation with multiple elements.

  • Setting up an animation that fades the text out and increases the opacity of an image based on the scroll position.
  • Fine-tuning the animation range with 'exit' and pixel offsets to control when the animation starts and ends.
  • Applying a 'forwards' animation fill mode to ensure the animation's final state is maintained after scrolling.

More Kevin Powell summaries

A practical guide to responsive web design

A practical guide to responsive web design

Kevin Powell

Kevin Powell

A detailed exploration of strategies for writing effective and responsive CSS for modern web design.

The background values no one knows about

The background values no one knows about

Kevin Powell

Kevin Powell

The video discusses two lesser-known CSS background repeat properties: space and round, and demonstrates their use with a star rating example.

Avoid these 5 beginner CSS mistakes

Avoid these 5 beginner CSS mistakes

Kevin Powell

Kevin Powell

The video discusses common CSS mistakes made by beginners, with demonstrations and solutions.