1. 互动性
  2. cursor

互动性

cursor

用于控制鼠标悬停在元素上时的光标样式的工具。

样式
cursor-auto
cursor: auto;
cursor-default
cursor: default;
cursor-pointer
cursor: pointer;
cursor-wait
cursor: wait;
cursor-text
cursor: text;
cursor-move
cursor: move;
cursor-help
cursor: help;
cursor-not-allowed
cursor: not-allowed;
cursor-none
cursor: none;
cursor-context-menu
cursor: context-menu;

示例(Examples)

¥Examples

基本示例(Basic example)

¥Basic example

使用像 cursor-pointercursor-grab 这样的工具来控制哪个光标悬停在元素上时显示:

¥Use utilities like cursor-pointer and cursor-grab to control which cursor is displayed when hovering over an element:

悬停在每个按钮上以查看光标变化

<button class="cursor-pointer ...">Submit</button>
<button class="cursor-progress ...">Saving...</button>
<button class="cursor-not-allowed ..." disabled>Confirm</button>

使用自定义值(Using a custom value)

¥Using a custom value

使用 cursor-[<value>] 语法 根据完全自定义的值设置 cursor

<button class="cursor-[url(hand.cur),_pointer] ...">
<!-- ... -->
</button>

对于 CSS 变量,还可以使用 cursor-(<custom-property>) 语法:

<button class="cursor-(--my-cursor) ...">
<!-- ... -->
</button>

这只是简写,用于 cursor-[var(<custom-property>)] 它会自动为你添加 var() 函数。

响应式设计(Responsive design)

¥Responsive design

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

<button class="cursor-not-allowed md:cursor-auto ...">
<!-- ... -->
</button>

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

TailwindCSS v4.0 中文网 - 粤ICP备13048890号