display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
gap: 8px;CSS Flexbox (Flexible Box Layout) is a one-dimensional layout model that provides an efficient way to distribute space and align items within a container. This interactive flexbox sandbox lets you experiment with every flexbox property in real time — adjust flex-direction, justify-content, align-items, flex-wrap, and gap with instant visual feedback. The generated CSS code updates automatically and can be copied with a single click.
The flex-direction property controls the main axis direction — row (left-to-right), row-reverse (right-to-left), column (top-to-bottom), or column-reverse (bottom-to-top). justify-content aligns items along the main axis with options like space-between (even spacing with no end gaps) and center (items clustered in the middle). align-items controls alignment on the cross axis — stretch fills the container height, while center, flex-start, and flex-end position items at different vertical locations. flex-wrap determines whether items stay on one line (nowrap) or wrap to the next (wrap, wrap-reverse). The gap property adds consistent spacing between all flex items.
justify-content: space-between with a fixed number of items to create evenly spaced navigation links with the last item pushed to the right edge.flex-wrap: wrap with gap to build responsive grids without media queries — items automatically break to the next line when the container shrinks.min-width or flex-basis on flex children to control their minimum size, preventing items from becoming too squished as the container shrinks.align-self on individual flex items to override the container's align-items — perfect for making one item taller or differently aligned than its siblings.flex: 1 to each flex child. This distributes remaining space evenly, creating proportional layouts without fixed widths.justify-content controls alignment along the main axis (the direction set by flex-direction). For a row direction, this is horizontal alignment. align-items controls alignment along the cross axis (perpendicular to the main axis). For a row direction, this is vertical alignment. Think of justify as the main axis and align as the cross axis.flex-wrap: wrap is set, items that don't fit in the container width automatically move to the next line. The gap property adds consistent spacing both between items in the same row and between rows of wrapped items. This combination lets you create responsive grids without media queries — items wrap naturally at every breakpoint while maintaining even spacing.space-between distributes items evenly along the main axis with the first item flush against the start edge and the last item flush against the end edge. space-around distributes items with equal space around each item — the space before the first item and after the last item is half the space between items. space-evenly (the newest option) gives exactly equal space between all items, including before the first and after the last item.flex-wrap: wrap. To force wrapping, add min-width or flex-basis values on flex items that collectively exceed the container width. You can also set flex: 0 0 200px to give each item a fixed base width.Want to master both layout systems? Try the CSS Grid Builder to compare flexbox and grid layouts. Also check out the Box Shadow Generator to style your flex items. Part of the FreeQ.One tools suite.