Skip to main content Skip to docs navigation

文本截断

用省略号截断长字符串。

对于较长的内容,您可以添加一个 .text-truncate 类来截断文本并用省略号表示。 需要 display: inline-blockdisplay: block

This text is quite long, and will be truncated once displayed.
This text is quite long, and will be truncated once displayed.
<!-- Block level -->
<div class="row">
  <div class="col-2 text-truncate">
    This text is quite long, and will be truncated once displayed.
  </div>
</div>

<!-- Inline level -->
<span class="d-inline-block text-truncate" style="max-width: 150px;">
  This text is quite long, and will be truncated once displayed.
</span>