Skip to content

Word Break 断词

控制元素中断词的实用程序。

ClassProperties

基本用法

Normal 正常

使用 break-normal 只在普通断词点添加换行符。

The longest word in any of the major English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.

html
<p class="break-normal ...">...</p>

Break Words 打破言语

如有需要,可使用 break-words 来在单词中间添加换行符。

The longest word in any of the major English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.

html
<p class="break-words ...">...</p>

Break All 全部换行

使用 break-all 在必要时添加换行符,而不必试图保留整个单词。

The longest word in any of the major English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.

html
<p class="break-all ...">...</p>

Break Keep 断开保持

使用 break-keep 来防止中文/日文/韩文(CJK)文本被应用换行。对于非 CJK 文本, break-keepbreak-normal 具有相同的行为。

抗衡不屈不挠 (kànghéng bùqū bùnáo) 这是一个长词,意思是不畏强暴,奋勇抗争,坚定不移,永不放弃。这个词通常用来描述那些在面对困难和挑战时坚持自己信念的人, 他们克服一切困难,不屈不挠地追求自己的目标。无论遇到多大的挑战,他们都能够坚持到底,不放弃,最终获得胜利。

html
<p class="break-keep ...">...</p>

有条件地应用

悬停、焦点和其他状态

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

html
<p class="break-normal hover:break-all">
  <!-- ... -->
</p>

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

断点和媒体查询

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

html
<p class="break-normal md:break-all">
  <!-- ... -->
</p>

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

Released under the MIT License.