1. 布局
  2. 超滚行为

布局

overscroll-behavior

用于控制浏览器在滚动区域边界处的行为的工具类。

ClassStyles
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>

响应式设计

Prefix an overscroll-behavior utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="overscroll-auto md:overscroll-contain ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.