What does flex: 1 mean?

Md. Rafee picture Md. Rafee · May 23, 2016 · Viewed 106k times · Source

As we all know, the flex property is a shorthand for the flex-grow, flex-shrink, and the flex-basis properties. Its default value is 0 1 auto, which means

flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;

but I've noticed, in many places flex: 1 is used. Is it shorthand for 1 1 auto or 1 0 auto? I can't understand what it means and I get nothing when I google.

Answer

Dhaval Chheda picture Dhaval Chheda · May 23, 2016

flex: 1 means the following:

flex-grow : 1;    ➜ The div will grow in same proportion as the window-size       
flex-shrink : 1;  ➜ The div will shrink in same proportion as the window-size 
flex-basis : 0;   ➜ The div does not have a starting value as such and will 
                     take up screen as per the screen size available for
                     e.g:- if 3 divs are in the wrapper then each div will take 33%.