word-break
用于控制元素内单词换行的工具类。
快速参考
| 类 | 属性 |
|---|---|
break-normal | word-break: normal; |
break-all | word-break: break-all; |
break-keep | word-break: keep-all; |
示例
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.
<!-- [!code classes:break-normal] -->
<p class="break-normal">The longest word in any of the major...</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.
<!-- [!code classes:break-all] -->
<p class="break-all">The longest word in any of the major...</p>Break Keep
使用 break-keep 工具类阻止对中文/日文/韩文(CJK)文本应用换行:
抗衡不屈不挠 (kànghéng bùqū bùnáo) 这是一个长词,意思是不畏强暴,奋勇抗争,坚定不移,永不放弃。 这个词通常用来描述那些在面对困难和挑战时坚持自己信念的人, 他们克服一切困难,不屈不挠地追求自己的目标。无论遇到多大的挑战,他们都能够坚持到底,不放弃,最终获得胜利。
<!-- [!code classes:break-keep] -->
<p class="break-keep">抗衡不屈不挠...</p>对于非 CJK 文本,break-keep 工具类的行为与 break-normal 相同。
响应式设计
使用 md: 等断点变体作为 word-break 工具类的前缀,即可只在中等屏幕尺寸及以上应用该工具类:
<p class="break-normal md:break-all ...">
Lorem ipsum dolor sit amet...
</p>更多关于变体的用法,请参阅变体文档。