1. Interactivity
  2. scroll-behavior

Interactivity

scroll-behavior

用于控制元素滚动行为的工具类。

ClassStyles
scroll-auto
scroll-behavior: auto;
scroll-smooth
scroll-behavior: smooth;

示例

使用平滑滚动

使用 scroll-smooth 工具类在元素内启用平滑滚动:

<html class="scroll-smooth">  <!-- ... --></html>

设置 scroll-behavior 仅影响由浏览器触发的滚动事件。

使用正常滚动

使用 scroll-auto 工具类恢复浏览器默认的滚动行为:

<html class="scroll-smooth md:scroll-auto">  <!-- ... --></html>
版权所有 © 2025 Tailwind Labs Inc.·商标政策