I've started using the flexbox recently and there often comes the situation where I need to distribute space on the main axis between elements.
I often hesitate between width
and flex-grow
. For example, if I want one item to measure 2 measures, and the other 1 measure, adding up to 100%, I have two choices. I can either set width: 66.6%
and width: 33.3%
, or flex-grow: 2
and flex-grow: 1
.
Sometimes if I want one element to grow the rest of the space, I can either do width: 100%
or flex-grow: 1
.
How do I choose? What are the differences/considerations in using width vs. flex-grow?
See Question&Answers more detail:os