0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Bootstrap】長文を「...」を使って省略する方法

Posted at

はじめに

今回は、テキストを全て表示せずに省略したいなってときに使える方法についてまとめます。
といっても、Bootstrapを使ったら一瞬なのですが、、、

text-truncate

index.blade.php
<div class="row">
   <div class="col-6">
       ---省略---
   </div
   <div class="col-6">
       <h3>{{ $menu_name }}</h3>
       <p class="text-truncate" style="max-width:200px;">{{ $ing }}</p>
   </div>
</div>

このように、text-truncateを使うと、指定した幅で文章が切られ、その代わりに...が表示されることになります。
max-widthを指定しなくても、要素の幅で切られるので問題なく動作します。

スクリーンショット 2021-11-09 18.07.27.png

インラインレベルでの動作は未確認ですが、d-inline-blockクラスを追加したり、max-widthを指定したりする必要があるようです。

引用

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?