Vertical flex:1 with overflow scrolling

I started to use the new Flexbox syntax in a couple places and often needed something to be vertically flexible, but when content starts to overflow, it should add a scrollbar.

First I tried it like this:

flex: 1;
overflow: auto;

but somehow it didn’t work. Just when adding height/min-height:0 it works.

flex: 1;
overflow: auto;
min-height: 0;

Not sure if that’s the intended behavior or a bug. Anyways, happy there is a simple fix for it. You can test it in this demo.

Update: Ivan points out that flex: 1 is not even needed. So the simplest way is just this:

overflow: auto;
min-height: 0;
  1. jakebresnehan reblogged this from simurai
  2. jmlweb reblogged this from simurai
  3. idrakimuhamad reblogged this from simurai
  4. naguyin reblogged this from simurai
  5. highlycuratedidiocy said: That is really interesting behavior, neat!
  6. simurai posted this
simurai simurai

I’m a UIX Designer and like to experiment with CSS3. This site is my personal playground.

About
Contact