0
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?

k.k.FactoryAdvent Calendar 2024

Day 13

CSSを学びたい!Step13 (長い文字を省略する)

Posted at

はじめに

CSSを学びたいStep13です!長い文字を省略するellipsisを紹介します!

成果物

image.png

ソースコード

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>テキスト省略の例</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="ellipsis">これは非常に長いテキストで、幅を超えると省略されます。</div>
</body>
</html>
styles.css
.ellipsis {
    white-space: nowrap; /* テキストを折り返さない */
    overflow: hidden; /* はみ出した部分を隠す */
    text-overflow: ellipsis; /* はみ出した部分を「...」で表示 */
    width: 200px; /* 必要に応じて幅を設定 */
}
0
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
0
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?