Scroll Snap new 滚动吸附 Scroll Snap web
A scrolling container that settles on intentional item or page boundaries
滚动容器停在预先定义的卡片或页面边界上
标本可交互,可以直接操作。
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Snap container吸附容器
scroll-snap-typeThe scrolling element that defines the snap axis and strictness.
定义滚动轴和吸附严格程度的滚动元素。
Prompt fragmentPrompt 片段a horizontal or vertical overflow container with scroll-snap-type set deliberately for discrete panels
一个明确设置 scroll-snap-type 的横向或纵向溢出容器,用于离散面板
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Build a scroll-snap section rail with scroll-snap-type: y mandatory (or x mandatory for a carousel), scroll-snap-align: start on each panel, enough scroll padding for fixed UI, and a proximity fallback when strict snapping would fight natural reading.
构建一个滚动吸附区块轨道:轮播使用 scroll-snap-type: x mandatory,整屏区块使用 y mandatory;每个面板设置 scroll-snap-align: start;为固定 UI 预留 scroll-padding;严格吸附会影响阅读时改用 proximity。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my scroll snap. Check that the container owns the overflow, children have scroll-snap-align, the axis matches the content flow, fixed headers are included in scroll-padding, nested scrollers do not chain unexpectedly, and mandatory snapping is avoided for long text panels. The symptom:
调试我的滚动吸附。检查 overflow 是否在正确的容器上;子项有 scroll-snap-align;轴向与内容流一致;固定头部已计入 scroll-padding;嵌套滚动不会意外串联;长文本面板避免使用 mandatory。症状:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| CSS | scroll-snap-type | declare the axis and mandatory or proximity behavior声明滚动轴和 mandatory 或 proximity 行为 |
| CSS | scroll-snap-align | mark the alignment edge for each child标记每个子项的对齐边缘 |
| CSS | overscroll-behavior | keep nested snapping from chaining unexpectedly避免嵌套吸附意外串联 |