How do I set distance between flexbox items?
How do I set distance between flexbox items?
16105-Jun-2024
Updated on 06-Jun-2024
Home / DeveloperSection / Forums / How do I set distance between flexbox items?
How do I set distance between flexbox items?
Ashutosh Kumar Verma
06-Jun-2024Set distance between flexbox items
You can use the
gap
property to set the distance between flexbox items. Thegap
property is a brief ofrow-gap
andcolumn-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
.container
class, and it sets a gap of10px
between flex items.Also, you can use margins on flex items to create space between them
The
gap
property 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?