Overscroll Behavior 滚动超出行为
用于控制浏览器在到达滚动区域边界时的行为的实用工具。
| Class | Properties |
|---|
基本用法
防止父级滚动超出
使用 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 ...">Well, let me tell you something, ...</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 ...">Well, let me tell you something, ...</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 ...">Well, let me tell you something, ...</div>有条件地应用
悬停,焦点和其他状态
Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 focus:overscroll-contain 只在焦点上应用 overscroll-contain 实用程序。
<html class="overscroll-auto focus:overscroll-contain">
<!-- ... -->
</html>要查看所有可用状态修饰符的完整列表,请查看悬停,焦点和其他状态文档。
断点和媒体查询
您还可以使用变体修饰符来定位媒体查询,如响应式断点、暗模式、偏好减少动作等。例如,使用 md:overscroll-contain 仅在中等屏幕尺寸及以上应用 overscroll-contain 实用程序。
<html class="overscroll-auto md:overscroll-contain">
<!-- ... -->
</html>