Skip to main content Skip to docs navigation
View on GitHub

文字截斷 (Text truncation)

使用刪節號截斷較長的字串。

六角學院的 Bootstrap 5 課程上線囉,立即與萬人一同學習最專業、最深入的 Bootstrap 5 課程。

立即上課去

對於較長的內容,可以添加 .text-truncate 類別,以透過刪節號截斷文字。需為 display: inline-block 或是 display: 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>