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.

横スクロール可能な要素内のflexbox要素のwidthが途中で切れてしまうときの対処

Last updated at Posted at 2018-08-13

現象

  • スクロール可能な要素内のflexbox要素サイズが途中で切れる。(本当はスクロールしたら全部で2000pxあるはずなのにスクロールしない状態の1200pxになる等)
  • その影響でflexbox要素のスタイル(backgroundやborder)が途中で切れる。
  • position: sticky が途中で解除されてしまう。
<div class="table">
  <div class="line">
    <div class="cell">aaa</div>
    <div class="cell">bbb</div>
    <div class="cell">ccc</div>
    <div class="cell">ddd</div>
    <div class="cell">eee</div>
  </div>
</div>
.table {
  overflow-x: auto;
}
.line {
  display: flex;
}
.cell {
  width: 400px;
}

対処

  • .linemin-width: min-content を追加

他に試したこと

  • .linewidth: 100% を追加 → 何も変わらず
  • .linealign-items: flex-start を追加 → 何も変わらず
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?