示例工程 11-positioning

11-positioning/demo-02-fixed-sticky/README.md

markdown · 0.3 KB

运行:fixed 与 sticky

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

# demo-02-fixed-sticky

fixed 按钮相对视口;sticky 标题在滚动区顶部粘住。

## 运行

直接打开 `index.html`,滚动内部区域与整个页面。

## 观察

- fixed 按钮不随页面滚动
- sticky 标题只在滚动区内粘住,离开容器就恢复
- sticky 需要 `top` 阈值,否则不生效