Sometimes, we want to make flex items take content width, not the width of the parent container with CSS.
In this article, we’ll look at how to make flex items take content width, not the width of the parent container with CSS.
How to make flex items take content width, not the width of the parent container with CSS?
To make flex items take content width, not the width of the parent container with CSS, we can set the align-self
property.
For instance, we write
div {
align-items: flex-start;
}
to add align-items: flex-start;
to make flex items take content width, not the width of the parent container.
Conclusion
To make flex items take content width, not the width of the parent container with CSS, we can set the align-self
property.