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.
html
<!-- 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>