CSS Flexbox Generator

Change direction, justify-content, align-items, wrap and gap and watch the boxes move, then copy the CSS.

Processed on your device. Files are not uploaded

How to try flexbox settings

  1. Choose the settings

    Direction, justify-content, align-items, wrap and gap.

  2. Check the preview

    Watch the live preview change as you adjust.

  3. Copy the CSS

    Paste the rules onto your container.

Worked example

This is what CSS Flexbox Generator gives for its own sample values. Open the tool above and change anything to try your own.

flex-direction
row
justify-content
flex-start
align-items
stretch
flex-wrap
nowrap
gap (px)
8
Boxes to preview
4

CSS

display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
gap: 8px;

About CSS Flexbox Generator

Change the main flexbox properties and watch the boxes move. The preview helps you understand what justify-content and align-items do on each axis, and it gives you the CSS to copy.

FAQs

What is the difference between justify-content and align-items?

justify-content spreads items along the main axis, which is horizontal for a row. align-items places them across it.

Why did the boxes stretch?

align-items: stretch is the default and makes items fill the cross axis. Choose flex-start to stop that.

When should I use grid instead?

Use CSS Grid Generator for layouts in rows and columns together.

Related tools