flex-wrap in CSS – How to Wrap Overflown Flex Items
flex-wrap specifies whether browsers should wrap overflown flexible items onto multiple lines.
The flex-wrap
property accepts the following values:
nowrap
wrap
wrap-reverse
Let’s discuss the three values below.
What Is flex-wrap: nowrap
in CSS Flexbox?
nowrap
is flex-wrap
’s default value. It forces all items within a flexible container into a single line (that is, row-wise or column-wise direction).
In other words, nowrap
tells browsers not to wrap a flexible container’s items.
Here’s an example:
The snippet above used nowrap
to force browsers to lay out the flexible containers’ items in a single line.
What Is flex-wrap: wrap
in CSS Flexbox?
wrap
moves all overflown items within a flexible container to the next line.
In other words, wrap
tells browsers to wrap a flexible container’s overflown items.
Here’s an example:
We used wrap
to wrap the flexible containers’ overflown items to the next line.
What Is flex-wrap: wrap-reverse
in CSS Flexbox?
wrap-reverse
moves all overflown items within a flexible container to the next line in reverse order.
Here’s an example:
We used wrap-reverse
to wrap the flexible containers’ overflown items to the next line in reverse order.