overscroll-behavior
快速参考
| 类 | 样式 |
|---|---|
| overscroll-auto | overscroll-behavior: auto; |
| overscroll-contain | overscroll-behavior: contain; |
| overscroll-none | overscroll-behavior: none; |
| overscroll-x-auto | overscroll-behavior-x: auto; |
| overscroll-x-contain | overscroll-behavior-x: contain; |
| overscroll-x-none | overscroll-behavior-x: none; |
| overscroll-y-auto | overscroll-behavior-y: auto; |
| overscroll-y-contain | overscroll-behavior-y: contain; |
| overscroll-y-none | overscroll-behavior-y: none; |
示例
阻止父元素过度滚动
使用 overscroll-contain 实用工具来阻止目标区域的滚动触发父元素的滚动,但在支持此功能的操作系统中,当滚动超出容器末端时,保留 “回弹” 效果:
滚动查看效果
Well, let me tell you something, funny boy. Y'know that little stamp, the one that says "New York Public Library"? Well that may not mean anything to you, but that means a lot to me. One whole hell of a lot.
Sure, go ahead, laugh if you want to. I've seen your type before: Flashy, making the scene, flaunting convention. Yeah, I know what you're thinking. What's this guy making such a big stink about old library books? Well, let me give you a hint, junior.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better?
<div class="overscroll-contain ...">是这样的,我说你这滑稽的小家伙,...</div>
阻止过度滚动回弹
使用 overscroll-none 实用工具来阻止目标区域的滚动触发父元素的滚动,并阻止滚动超出容器末端时的“回弹”效果:
Well, let me tell you something, funny boy. Y'know that little stamp, the one that says "New York Public Library"? Well that may not mean anything to you, but that means a lot to me. One whole hell of a lot.
Sure, go ahead, laugh if you want to. I've seen your type before: Flashy, making the scene, flaunting convention. Yeah, I know what you're thinking. What's this guy making such a big stink about old library books? Well, let me give you a hint, junior.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better?
<div class="overscroll-none ...">是这样的,我说你这滑稽的小家伙,...</div>
使用默认的过度滚动行为
当用户到达主要滚动区域的边界时,使用 overscroll-auto 实用工具使其能够继续滚动父滚动区域:
滚动查看效果
Well, let me tell you something, funny boy. Y'know that little stamp, the one that says "New York Public Library"? Well that may not mean anything to you, but that means a lot to me. One whole hell of a lot.
Sure, go ahead, laugh if you want to. I've seen your type before: Flashy, making the scene, flaunting convention. Yeah, I know what you're thinking. What's this guy making such a big stink about old library books? Well, let me give you a hint, junior.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better?
<div class="overscroll-auto ...">是这样的,我说你这滑稽的小家伙,...</div>
响应式设计
使用断点变体(例如 md:)作为 overscroll-behavior 实用工具的前缀,以便仅在中等尺寸及以上的屏幕上应用该实用工具:
<div class="overscroll-auto md:overscroll-contain ...">
<!-- ... -->
</div>
在 变体文档 中了解更多关于使用变体的信息。