Posted 4 months ago. Visible to the public. Repeats. Linked content.

Do not use "flex: 1" or "flex-basis: 0" inside "flex-direction: column" when you need to support IE11

Flexbox is awesome. Most of it even works in IE11, but flex: 1 won't work reliably in Internet Explorer.
This it because implicitly sets flex-basis: 0 which IE fails to support properly.

Example

Consider the following HTML and CSS.

Copy
<div class="container"> <div class="child"> foo </div> <div class="bar"> bar </div> </div>
Copy
.container { display: flex; flex-direction: column; } .child { flex: 1; }

See it in action at Plunker.

Background

flex: 1 is a shortcut to flex-grow: 1 + flex-shrink: 1 + flex-basis: 0. A base size of zero is okay because the element would grow when needed.
In Internet Explorer, this only works when the flex container uses flex-direction: row. For flex-direction: column, children will overlap as if they would not consume any height.

How to fix

What works, and what you probably want anyway, is flex-basis: auto.

We recommend you use the flex shorthand property with all 3 values:

Copy
.container { display: flex; flex-direction: column; } .child { flex: 1 1 auto; }

In the example above, the flex children are allowed to grow and shrink, so the result will be the same. But using auto, it finally works in IE11.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Arne Hartherz
Last edit:
4 months ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more