Prevent flexbox shrinking

Simon Boudrias picture Simon Boudrias · Mar 20, 2015 · Viewed 48.1k times · Source

I'm using flexbox to layout a page because the growing behavior is useful. But I'd like to completely prevent the shrinking behavior.

Anyway to manage this?

Example code:

<div class="flex-vertical-container">
    <div class="flex-box">
         This one should grow but not shrink
    </div>
    <div></div>
    <div></div>
</div>

CSS

.flex-vertical-container {
    display: flex;
    flex-direction: column;
}

.flex-box {
    flex: 1;
}

Answer

zgood picture zgood · Mar 20, 2015

Try setting the flex-shrink property to 0 on the .flex-box.