18
9

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][メモ] IE11でflex-basisにbox-sizingが効かない

Posted at

以下のような、よくあるボックス横並びのUIをコーディングしていて遭遇したのでメモ。

ul {
  display: flex;
  flex-wrap: wrap;
  width: 960px;
  margin: 0 20px;
}

li {
  flex: 0 0 184px;
  height: 40px;
  padding: 10px;
  box-sizing: border-box;
}

上記のコードでChromeでは1行5列のリストが表示されるが、
IE11ではbox-sizingが効かず、5列目が落ちてしまう。

これに対処する為には、以下のようにmax-widthflex-basisと同値で指定する必要がある。

ul {
  display: flex;
  flex-wrap: wrap;
  width: 960px;
  margin: 0 20px;
}

li {
  flex: 0 0 184px;
  max-width: 184px; /* ← これを追加 */
  height: 40px;
  padding: 10px;
  box-sizing: border-box;
}

これでIE11でも正しく表示できる。

18
9
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
18
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?