Parallax Scrolling new 视差滚动 Parallax web
Layered motion where foreground and background travel at different rates
前景与背景以不同速度移动的分层滚动效果
标本可交互,可以直接操作。
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Depth layer纵深图层
transform: translate3d()One independently moving plane in the scene.
场景中独立移动的一个平面。
Prompt fragmentPrompt 片段a background, midground, or foreground layer with a small scroll-mapped transform and no layout reflow
一个背景、中景或前景图层,带小幅滚动映射 transform 且不触发布局重排
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Create a restrained parallax scene with separate background, midground, and foreground layers. Map scroll progress to small transform offsets, keep the focal content readable, avoid large motion that causes discomfort, and flatten the layers under prefers-reduced-motion.
创建一个克制的视差场景,分开背景、中景和前景图层。将滚动进度映射到小幅 transform 偏移,保持主体内容可读,避免大幅移动造成不适,并在 prefers-reduced-motion 下压平图层。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my parallax effect. Check that each layer has a stable containing block, transforms do not create horizontal overflow, updates are frame-scheduled, the movement range is subtle, images have reserved dimensions, and reduced motion disables the depth travel while preserving the scene. The symptom:
调试我的视差效果。检查每个图层有稳定的包含块;transform 不会制造横向溢出;更新按帧调度;移动范围足够克制;图片预留尺寸;减少动态效果时关闭纵深移动但保留场景。症状:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| CSS | transform: translateY() | move layers without reflow移动图层而不触发布局重排 |
| Web API | requestAnimationFrame | schedule scroll position updates efficiently高效调度滚动位置更新 |
| CSS | prefers-reduced-motion | flatten layers when motion is reduced减少动态效果时压平图层 |