交互

scrollbar-gutter

Utilities for controlling the gutter space reserved for an element's scrollbar.

ClassStyles
scrollbar-gutter-auto
scrollbar-gutter: auto;
scrollbar-gutter-stable
scrollbar-gutter: stable;
scrollbar-gutter-both
scrollbar-gutter: stable both-edges;

示例

为滚动条预留空间

使用 scrollbar-gutter-stable 工具,即使元素没有溢出,也为滚动条预留空间:

scrollbar-gutter-auto

嘿,大家好!现在已经快到 2027 年了,而我们仍然不知道是否有外星人生活在我们之中,还是说有呢?也许写这段话的人就是一个外星人。你永远不会知道。

scrollbar-gutter-stable

嘿,大家好!现在已经快到 2027 年了,而我们仍然不知道是否有外星人生活在我们之中,还是说有呢?也许写这段话的人就是一个外星人。你永远不会知道。

<div class="overflow-auto scrollbar-gutter-stable ...">  <!-- ... --></div>

两侧都预留空间

使用 scrollbar-gutter-both 工具,为元素两侧预留相匹配的槽位空间:

<div class="overflow-auto scrollbar-gutter-both ...">  <!-- ... --></div>

使用默认槽位

使用 scrollbar-gutter-auto 工具,仅在浏览器通常会显示滚动条时预留槽位空间:

<div class="overflow-auto scrollbar-gutter-auto ...">  <!-- ... --></div>

响应式设计

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

<div class="scrollbar-gutter-auto md:scrollbar-gutter-stable ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.