How do I set distance between flexbox items?
Ask by Sandra Emily
Updated 06 Jun 2024
Set distance between flexbox items
You can use the
gapproperty to set the distance between flexbox items. Thegapproperty is a brief ofrow-gapandcolumn-gap, and it specifies the gap between the rows and columns of a grid or flex container.Using with flexbox
In the above syntax, The gap property is applied to a flex container with the
.containerclass, and it sets a gap of10pxbetween flex items.Also, you can use margins on flex items to create space between them
The
gapproperty is recommended for creating space between flex items, as it is cleaner and built-in, especially when working with flexible layouts.Example-
Output-
Also, Read: How do you create a button with borderless CSS?