How to make flex items take content width, not the width of the parent container with CSS?

Spread the love

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.

Leave a Reply

Your email address will not be published.