Skip to content

Text Transform 文本转换

控制文本转换的实用工具。

ClassProperties

基本用法

转换文本

uppercaselowercase 分别将文本转换为大写和小写,而 capitalize 实用程序将文本转换为标题大小写。 normal-case 实用程序可用于保留原始大小写,通常在不同断点处重置大写。

normal-case

The quick brown fox jumps over the lazy dog.

uppercase

The quick brown fox jumps over the lazy dog.

lowercase

The quick brown fox jumps over the lazy dog.

capitalize

The quick brown fox jumps over the lazy dog.

html
<p class="normal-case ...">The quick brown fox ...</p>
<p class="uppercase ...">The quick brown fox ...</p>
<p class="lowercase ...">The quick brown fox ...</p>
<p class="capitalize ...">The quick brown fox ...</p>

有条件地应用

悬停、焦点和其他状态

Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:uppercase 只在悬停时应用 uppercase 实用程序。

html
<p class="capitalize hover:uppercase">
  <!-- ... -->
</p>

有关所有可用状态修改器的完整列表,请查看悬停、焦点和其他状态文档。

断点和媒体查询

您还可以使用变体修饰符来针对响应式断点、深色模式、prefers-reduced-motion 等媒体查询进行定位。例如,使用 md:uppercase 仅在中等屏幕尺寸及以上应用 uppercase 实用程序。

html
<p class="capitalize md:uppercase">
  <!-- ... -->
</p>

要了解更多信息,请查看有关响应式设计深色模式其他媒体查询修饰符的文档。

Released under the MIT License.