๐ŸŽจ CSS ยท GENERATOR

CSS Flexbox Generator

Build flex layouts visually: set the container, then fine-tune each item's flex-grow, flex-shrink, flex-basis, order and align-self. Copy clean CSS with matching HTML, or Tailwind classes.

Container + per-item settings ยท Presets ยท CSS, HTML & Tailwind
Tip: your layout is remembered on this device until you press Reset.Need rows and columns at the same time? CSS Grid Generator (coming soon)
Click the options or drag the sliders. The preview and code update live.
Settings

Presets

Container

display
flex-direction
flex-wrap
justify-content
align-items
align-content

    Items

    Select an item (or click it in the preview) to set its own flex values.

    Item 1

    flex-basis
    align-self
    Auto margin
    margin-left: auto pushes an item (and everything after it) to the right, a common trick for nav bars.

    Output

    Class name

    Preview size

    Only changes the preview box, so you can test wrapping. It isn't part of the code.
    Live preview
    Code
    โ—† ABOUT THIS TOOL

    What Is CSS Flexbox?

    A one-dimensional layout system for lining items up in a row or a column.

    Setting display: flex on an element makes it a flex container and its direct children flex items. Items line up along the main axis (a row by default, or a column with flex-direction: column). The cross axis runs at right angles to it.

    justify-content spreads items along the main axis and align-items lines them up on the cross axis. gap adds space between items without margins.

    Each item can grow into free space (flex-grow), shrink when space runs out (flex-shrink), and start from a base size (flex-basis). The flex shorthand sets all three at once, e.g. flex: 1 1 0% for equal-width columns.

    Flexbox is ideal for nav bars, toolbars, centring, media objects and cards that wrap. For two-dimensional page layouts (rows and columns lined up), use CSS Grid.

    ๐Ÿ“ CHEAT SHEET

    Flexbox Properties at a Glance

    Container properties go on the parent; item properties go on the children.

    โ†’

    flex-direction

    row (default), row-reverse, column, column-reverse. Sets the main axis.

    โ†ต

    flex-wrap

    nowrap (default) keeps items on one line; wrap lets them flow onto new lines.

    โ‡”

    justify-content

    Spacing on the main axis: flex-start, center, flex-end, space-between, space-around, space-evenly.

    โ‡•

    align-items / align-self

    Alignment on the cross axis for all items, or one item: stretch (default), flex-start, center, flex-end, baseline.

    โ‰ก

    align-content

    Spaces the lines of a wrapping container. It has no effect with nowrap.

    1

    flex: grow shrink basis

    flex: 1 = 1 1 0%, flex: auto = 1 1 auto, flex: none = 0 0 auto. The default is 0 1 auto.

    โ— THREE STEPS

    How to Use the CSS Flexbox Generator

    Get your result in under ten seconds.

    1

    Pick a preset or start fresh

    Try Navbar, Equal columns, Sidebar or Wrapping cards, or set the container options yourself.

    2

    Tune the items

    Add or remove items, select one and set its grow, shrink, basis, order or alignment. Resize the preview box to test wrapping.

    3

    Copy the code

    Switch between CSS, HTML and Tailwind and press Copy.

    โœ“ FEATURES

    Why Use the CSS Flexbox Generator on Developers Web Tools

    Fast, accurate and private โ€” built for developers.

    ๐Ÿ‘

    True preview

    The preview uses exactly the CSS you copy, so what you see is what you get.

    ๐Ÿงฉ

    Per-item control

    Set flex-grow, shrink, basis, order, align-self and auto margins for each item.

    ๐Ÿ’ก

    Helpful warnings

    Tells you when a setting has no effect, such as align-content without wrapping.

    ๐ŸŒ€

    Tailwind output

    Get the same layout as Tailwind utility classes.

    ๐Ÿงพ

    Clean code

    Defaults are left out unless you ask for them.

    ๐Ÿ”’

    Private

    Runs entirely in your browser. Nothing is uploaded.

    FAQ

    Frequently Asked Questions

    Put display: flex; justify-content: center; align-items: center; on the parent. The container needs a height (or to be inside something with a height) for vertical centring to be visible. Try the Center preset.

    It's short for flex: 1 1 0%: the item can grow and shrink, and starts from a size of zero, so all items with flex: 1 end up the same width.

    justify-content works along the main axis (horizontal in a row) and align-items along the cross axis (vertical in a row). With flex-direction: column they swap.

    It only spaces the lines of a container that can wrap. Set flex-wrap: wrap and make sure there's spare height in the container.

    If an item has flex-grow or an auto margin, it takes up all the free space on its line, so there's nothing left for justify-content to share out.

    order changes only the visual order. Keyboard focus and screen readers still follow the HTML order, so keep the HTML in a logical order.

    Yes, in all current browsers (Chrome 84+, Firefox 63+, Safari 14.1+).

    Gaps on Tailwind's spacing scale use its classes (gap-3 = 0.75rem = 12px at the default 16px font size); other values use exact arbitrary values like gap-[13px]. Flex-basis always uses an exact value, e.g. basis-[200px].

    Only in your own browser (local storage), so it's still there next time. Press Reset to clear it.