LoginSignup
2
0

More than 3 years have passed since last update.

親要素の幅を超えたときのいろいろ

Posted at

通常時

通常時は以下のように子要素の幅が親要素を超えた場合は文字が折り返される。

<body>
  <div class="box">
    <p>あああああああああああああ</p>
  </div>
</body>
.box {
  border: 1px solid red;
  height: 100px;
  width: 100px;
}

スクリーンショット 2019-11-06 18.31.54.png

折り返しを禁止する

.box {
  border: 1px solid red;
  height: 100px;
  width: 100px;
  white-space: nowrap;
}

white-space: nowrap;とすることで、折り返しを禁止する。

スクリーンショット 2019-11-06 18.34.52.png

はみ出した文字を非表示にする


.box {
  border: 1px solid red;
  height: 100px;
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
}

white-space: nowrap;overflow: hidden;を組み合わせることで実現

スクリーンショット 2019-11-06 18.38.24.png

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