Skip to main content Skip to docs navigation

文字截断(Text truncation)

用省略号截断长文本串。

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