Skip to content

Text Align 文本对齐

控制文本对齐的实用工具。​

ClassProperties

基本用法

设置文本对齐

使用 text-lefttext-centertext-righttext-justify 实用程序控制元素的文本对齐方式。

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

html
<p class="text-left ...">So I started to walk into the water...</p>

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

html
<p class="text-center ...">So I started to walk into the water...</p>

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

html
<p class="text-right ...">So I started to walk into the water...</p>

So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I was a marine biologist.

html
<p class="text-justify ...">So I started to walk into the water...</p>

有条件地应用

悬停、焦点和其他状态

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

html
<p class="text-left hover:text-center">
  <!-- ... -->
</p>

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

断点和媒体查询

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

html
<p class="text-left md:text-center">
  <!-- ... -->
</p>

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

Released under the MIT License.