IT技术博客大学习 共学习 共进步
全部 移动开发 后端 数据库 AI 算法 安全 DevOps 前端 设计 开发者

Scroll-Driven, Scroll-Triggered, Scroll States, and View Transitions

CSS-Tricks 2026-06-14 05:11:01 累计浏览 2 次
本机暂存

I’ve said one and meant another, and I’ve used one when I needed another. Please bear with me as I note the high-level similarities and differences between scroll-driven animations, scroll-triggered animations, container query scroll states, and view transitions for my future self.

Scroll-Driven Animations

A scroll-driven animation is an animation that responds to, yeah, scrolling. Specifically, there’s a direct link between scrolling progress and the animation’s progress. Scroll forwards, the animation moves forward. Scroll backwards, the animation runs backwards. Stop scrolling, the animations stops.

.element {
  animation: grow-progress linear forwards;
  animation-timeline: scroll();
}
CodePen Embed Fallback

Scroll-Triggered Animations

A scroll-triggered animation executes on scroll and runs in its entirety. In other words, there’s no direct link with the scroll progress here. When an element crosses some defined threshold — called the trigger activation range — the animation runs, runs, runs. For example, when that element enters and exits the scrollport.

CodePen Embed Fallback

Container Query Scroll State

This one’s in the working draft of CSS Conditional Rules Module Level 5 specification. Here’s how the spec defines it:

[…] allows querying a container for state that depends on scroll position. 

This is why my brain hurts so much. It’s sorta like a scroll-driven animation, sorta like a scroll-triggered animation, but updates styles when a container reaches some sort of scroll condition, say:

.sticky-nav {
  container-type: scroll-state;
  position: sticky;
  top: 0;

  @container scroll-state(stuck: top) {
    background: orangered;
    border-radius: 0;
    flex-direction: row;
    width: 100%;

    a {
      text-decoration: none;
    }
  }
}
CodePen Embed Fallback

View Transition

This has nothing to do with scroll! And it has nothing to do with view(). We’re actually talking about a complete API with interlocking CSS and JavaScript features that can do two things:

Same-document transitions

An element changes from one state to another in response to a user interaction. I was really tickled by this one from Modern Web Weekly animating radio button check states where the state moves from one input to the other.

CodePen Embed Fallback

Basically, the state changes on the same page it started. Bramus is king of all-thing view transitions with oodles of beautiful examples in this collection from the Chrome team.

Cross-document transitions

Animating from one page to the next. The default usage is a crossfade from Page A to Page B (and back again) and is really easy to implement. It can get much more complex from there, of course. Sunkanmi recently shared several recipes, like this neat one that wipes out the first page with a circular clip-path revealing the second page.

That’s all!

It helps me to spell things out like this.

TypeWhat it does
Scroll-Driven AnimationsScroll forwards, the animation moves forward. Scroll backwards, the animation runs backwards. Stop scrolling, the animations stops.
Scroll-Triggered AnimationsWhen an element crosses some defined threshold — called the trigger activation range — the animation runs, runs, runs.
Container Query Scroll StateUpdates styles when a container reaches some sort of scroll condition.
View TransitionAPI for same-document transitions (element changes from one state to another on the page) and cross-document transitions (transitioning from one page to the next, and back).

Scroll-Driven, Scroll-Triggered, Scroll States, and View Transitions originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.

同分类推荐文章

  1. Why Isn’t My 3D View Transition Working? (2026-06-12 20:53:41)
  2. 全新的CSS border-shape属性简介 (2026-06-10 11:00:06)
  3. 如何:不借助第三方服务粗略检测访客是否来自中国大陆 (2026-06-08 15:24:19)

查看更多 前端 文章 →

建议继续学习

  1. 50个活力和动感的网页设计-颜色的灵感 (累计阅读 34,380)
  2. 视觉设计前瞻实用性研究(PNVD) 第二期 (累计阅读 12,921)
  3. 各公司对前端开发的职位描述 (累计阅读 10,360)
  4. iframe大小自适应 (累计阅读 9,996)
  5. 浏览器的渲染原理简介 (累计阅读 8,302)
  6. 解决IE6从Nginx服务器下载图片不Cache的Bug (累计阅读 8,294)
  7. 程序员眼里IE浏览器是什么样的 (累计阅读 7,956)
  8. 2010网页设计趋势 (累计阅读 7,752)
  9. Web前端工程师编程能力飞升之路 (累计阅读 7,639)
  10. 颜色的代码表达式 (累计阅读 7,618)