Sometimes, we want to fix flexbox not giving equal width to elements with CSS.
In this article, we’ll look at how to fix flexbox not giving equal width to elements with CSS.
How to fix flexbox not giving equal width to elements with CSS?
To fix flexbox not giving equal width to elements with CSS, we need to set flex-basis
to a fixed value.
For instance, we write
li {
flex-grow: 1;
flex-basis: 0;
/* ... */
}
to set flex-basis
to 0 so that any remaining space will be distributed based on the flex-grow
value.
Conclusion
To fix flexbox not giving equal width to elements with CSS, we need to set flex-basis
to a fixed value.