23
21

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 5 years have passed since last update.

入らなかった文字を三点リーダで省略表示

Last updated at Posted at 2017-06-16

単数行の場合

text-overflow: ellipsisを使います。
親要素でwidthを指定し、overflow: hiddenで表示を消して、text-overflow: ellipsisで三点リーダー表示。
改行をさせたくないので、white-space: nowrap指定です。

sample.html
<div class="content">
  <p>長すぎて入りきらなかったテキストが入ります。</p>
</div>
sample.sass
.content
  overflow: hidden
  width: 100%
  p
    overflow: hidden
    text-overflow: ellipsis
    white-space: nowrap

プロパティ

エリア外を表示しない
overflow: hidden

切り取られたテキストの代わりに「…」をい表示
text-overflow: ellipsis

自動的に改行しない
white-space: nowrap

23
21
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
23
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?