排版
用于控制元素中文本溢出的实用程序。
使用 truncate
防止文本换行,并在必要时使用省略号 (…
) 截断溢出的文本。
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.
<p class="truncate ...">...</p>
如果需要,使用 text-ellipsis
和省略号 (…
) 截断溢出的文本。
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.
<p class="text-ellipsis overflow-hidden ...">...</p>
使用 text-clip
可在内容区域的限制处截断文本。
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.
<p class="text-clip overflow-hidden ...">...</p>
Tailwind 允许您使用变体修饰符有条件地在不同状态下应用实用程序类。例如,使用 hover:text-clip
来仅 在 hover应用 text-clip
.
<p class="truncate hover:text-clip">
<!-- ... -->
</p>
详细了解, 请参考 Hover, Focus, & Other States 文档.
您还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗模式、首选减少运动等。例如, 使用 md:text-clip
来应用 text-clip
程序,适用于中等屏幕尺寸及以上。
<p class="truncate md:text-clip">
<!-- ... -->
</p>