Understanding the difference between the flex and flex-grow properties
What is the difference in effect between setting flex: 1; and setting flex-grow: 1;? When I set the former in my code, the two columns I have display with equal width, while they do not do so when ...
stackoverflow.com
flex is a shorthand property of flex-grow, flex-shrink and flex-basis.
In this case, flex: 1 sets
- flex-grow: 1
- flex-shrink: 1
- flex-basis: 0 (in old spec drafts it was flex-basis: 0%)
If you only use flex-grow: 1, you will have
- flex-grow: 1
- flex-shrink: 1
- flex-basis: auto
Then, the difference is that the flex base size will be 0 in the first case, so the flex items will have the same size after distributing free space.
In the second case each flex item will start with the size given by its content, and then will grow or shrink according to free space. Most probably the sizes will end up being different.
'FE > React & RN' 카테고리의 다른 글
Atomic Design (아토믹 패턴) (0) | 2021.11.10 |
---|---|
[Mobx] (0) | 2021.08.02 |
[super props] TypeScript (0) | 2021.07.07 |
[react-saga] (0) | 2021.06.09 |
JSX란? (0) | 2021.05.26 |
댓글