1. 互动性
  2. scrollbar-width

互动性

scrollbar-width

用于控制元素滚动条宽度的工具。

样式
scrollbar-auto
scrollbar-width: auto;
scrollbar-thin
scrollbar-width: thin;
scrollbar-none
scrollbar-width: none;

示例(Examples)

使用默认滚动条宽度(Using the default scrollbar width)

使用 scrollbar-auto 工具来使用浏览器的默认滚动条宽度:

🌐 Use the scrollbar-auto utility to use the browser's default scrollbar width:

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

使用细滚动条(Using a thin scrollbar)

使用 scrollbar-thin 工具来使用更细的滚动条:

🌐 Use the scrollbar-thin utility to use a thinner scrollbar:

垂直滚动

The Cerulean Archives occupy three narrow floors above the old observatory, each lined with drawers of star maps, expedition notes, and brass instruments cataloged by hand.

On winter mornings, the staff rolls ladders between the shelves while pale light cuts through the roof windows and settles on the reading tables.

Visitors can request anything from the collection, but most come for the atlases that chart coastlines no longer found on modern maps.

Every returned volume is inspected, dusted, and wrapped before being carried back into the stacks for the next researcher.

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

隐藏滚动条(Hiding scrollbars)

使用 scrollbar-none 工具在仍然允许元素滚动的情况下隐藏滚动条:

🌐 Use the scrollbar-none utility to hide scrollbars while still allowing an element to scroll:

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

这些工具仅支持浏览器关键词 autothinnone

🌐 These utilities only support the browser keywords auto, thin, and none.

响应式设计(Responsive design)

scrollbar-width 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:

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

请参阅 变体文档 详细了解如何使用变体。

TailwindCSS 中文网 - 粤ICP备13048890号