排版
用于控制文本在元素内换行方式的实用程序。
使用 text-wrap
将溢出的文本在文本中的逻辑点处换行到多行。
New Yorkers are facing the winter chill with less warmth this year as the city's most revered soup stand unexpectedly shutters, following a series of events that have left the community puzzled.
<article class="text-wrap ...">
<h3>Beloved Manhattan soup stand closes</h3>
<p>New Yorkers are facing the winter chill...</p>
</article>
使用 text-nowrap
来防止文本换行,必要时允许其溢出。
New Yorkers are facing the winter chill with less warmth this year as the city's most revered soup stand unexpectedly shutters, following a series of events that have left the community puzzled.
<article class="text-nowrap ...">
<h3>Beloved Manhattan soup stand closes</h3>
<p>New Yorkers are facing the winter chill...</p>
</article>
使用 text-balance
将文本均匀分布在每一行。
New Yorkers are facing the winter chill with less warmth this year as the city's most revered soup stand unexpectedly shutters, following a series of events that have left the community puzzled.
<article>
<h3 class="text-balance ...">Beloved Manhattan soup stand closes</h3>
<p>New Yorkers are facing the winter chill...</p>
</article>
出于性能原因,浏览器将文本平衡限制至约 6 行或更少的块,使其最适合标题。
使用 text-pretty
来防止文本块末尾出现孤儿词(单个单词占据一行)。
New Yorkers are facing the winter chill with less warmth this year as the city's most revered soup stand unexpectedly shutters, following a series of events that have left the community puzzled.
<article class="text-pretty ...">
<h3>Beloved Manhattan soup stand closes</h3>
<p>New Yorkers are facing the winter chill...</p>
</article>
Tailwind 允许您使用变体修饰符有条件地在不同状态下应用实用程序类。例如,使用 hover:text-balance
来仅 在 hover应用 text-balance
.
<h1 class="text-wrap hover:text-balance">
<!-- ... -->
</h1>
详细了解, 请参考 Hover, Focus, & Other States 文档.
您还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗模式、首选减少运动等。例如, 使用 md:text-balance
来应用 text-balance
程序,适用于中等屏幕尺寸及以上。
<h1 class="text-wrap md:text-balance">
<!-- ... -->
</h1>