跳到主要内容 跳到文档导航

用省略号截断长文本字符串。

对于较长的内容,您可以添加一个.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>