1
0

More than 1 year has passed since last update.

tailwind.cssで長い文字列を・・・にする方法【複数行】

Last updated at Posted at 2022-05-20

一行のみ

<div className="truncate">
  一行のみを・・・にする場合
</div>

複数行

ライブラリを導入
yarn add @tailwindcss/line-clamp
tailwind.config.js
module.exports = {
  plugins: [require('@tailwindcss/line-clamp'),],
};
2行
<div className="line-clamp-2">
 【2行】ゴリラゴリラゴリラゴリラゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
  ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
  ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
</div>
3行
<div className="line-clamp-3">
 【3行】ゴリラゴリラゴリラゴリラゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
  ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
  ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ ゴリラ
</div>
1
0
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
1
0