1
0

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.

CSSで文字列を...で省略する

Posted at

文章が超絶に長い時、
どうしても省略したい時。

設定するCSSは以下。

style.css
.short_object {
    width: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -o-text-overflow: ellipsis; /* Opera9,10対応 */
  }

上記のshort_objectを省略したいタグに設定するだけ。

index.html
<h4 class="short_object">オラオラオラオラオラオラ!!!!!!!!</h4>

出力結果

オラオラオ...

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?