Flexbox CSS ready
{{ summaryPrimary }}
{{ summaryLine }}
{{ badge.label }}
CSS Flexbox Generator inputs
Container selector for the generated flex rule.
Choose whether the container behaves as block flex or inline flex.
Sets the main axis used by justify-content.
Let items wrap instead of forcing one cramped line.
Main-axis alignment and spacing.
Cross-axis alignment for items inside each line.
Spacing between adjacent flex items.
Adds a separate selector for direct flex items.
Suffix appended after the container selector.
Extra-space share for each child item.
Tight-space shrink factor for each child item.
Use auto, 0, or a CSS length such as 16rem or 240px.
Allows long child content to shrink inside flex rows.
Cross-axis spacing for multiple flex lines.
Number of sample items used in the preview and scaffold.
{{ cssCode }}
{{ item.label }}
Scope Property Value Implementation note Copy
{{ row.scope }} {{ row.property }} {{ row.value }} {{ row.note }}
{{ htmlScaffold }}

        
Customize
Advanced
:

Introduction

Many interface parts have to stay usable when their content changes. A button row may gain another action, a navigation group may wrap on a phone, a card footer may need one item at the start and another at the end, and a sidebar stack may need consistent spacing even when labels have different lengths. CSS flexbox is built for that kind of one-direction layout where direct children share space inside a container.

The central idea is the main axis. A flex container lays its direct children along one primary direction, then uses the cross axis for perpendicular alignment. With row, the main axis normally runs inline across the page. With column, it runs vertically. Once the direction changes, alignment words change their practical meaning too: justify-content follows the main axis, while align-items works across it.

Common flexbox layout situations and choices
Layout situation Flexbox choice Common caution
Toolbar, button row, or card footer Choose the main-axis distribution, then align item heights on the cross axis. Long labels can overflow unless items are allowed to shrink.
Tag list or responsive chip group Allow wrapping and use gap for space between items and lines. align-content is only visible after multiple flex lines exist.
Vertical stack or sidebar group Use a column direction so the main axis runs from top to bottom. justify-content now moves content vertically, not horizontally.
Equal child cards Set a shared flex shorthand when children should grow or shrink together. The same child rule applies to every matched direct child.
Flexbox container diagram showing the main axis, cross axis, and wrapped item lines

Flexbox is often compared with CSS grid because both can build responsive layouts. The useful difference is the planning model. Grid is stronger when both rows and columns need named placement, explicit tracks, or a stable two-dimensional map. Flexbox is stronger when a group of items should flow in one direction, share leftover space, shrink when needed, and wrap as a set.

The biggest flexbox mistakes come from treating alignment properties as fixed horizontal or vertical controls. justify-content follows the main axis, align-items follows the cross axis for each line, and reverse directions change visual flow without changing the document order used by keyboards, screen readers, and copy-paste.

How to Use This Tool:

Build the container rule first, then use the preview, property notes, and starter markup to confirm that the chosen axis, wrapping, spacing, and optional child sizing match the component you are building.

  1. Enter CSS selector for the flex container. Simple class or ID selectors also shape the wrapper in HTML Scaffold; unsupported selector shapes fall back to safe starter markup.
  2. Set Display mode, Direction, and Wrap. The summary badge should report the expected horizontal, vertical, or reverse main axis.
  3. Choose Justify content, Align items, and Gap. Use Flex Preview to see whether items group, stretch, center, spread, or wrap as intended.
  4. Open Advanced when wrapped-line behavior matters. Align content changes spacing between flex lines only after wrapping creates more than one line.
  5. Turn on Include child sizing rule when every matched direct child should share one flex shorthand. Review Child selector suffix, Flex grow, Flex shrink, Flex basis, and Set min-width: 0.
  6. Adjust Preview items to approximate the count of real children, then compare Flex CSS, Flex Preview, Property Ledger, HTML Scaffold, and JSON.
  7. Copy or download the needed artifact. If Flex basis normalizes to auto after another value was typed, replace it with a supported keyword or length before using the CSS.

Interpreting Results:

Start with the summary and Flex CSS. The summary pairs the selected direction with the main-axis spacing value, which helps catch the common mistake where justify-content is expected to move items horizontally even though the direction is column-based.

Flex Preview is a layout rehearsal with sample labels, not proof that every real child will fit. Long words, icons, form controls, images, nested blocks, and existing width rules can all change the final result. Use the preview to compare alignment choices, then test the copied CSS in the actual component at narrow and wide widths.

CSS flexbox result surfaces and review cues
Result surface What it shows What to verify
Flex CSS The generated container rule and optional direct-child rule. Selector target, axis choices, gap unit, and whether the child rule should apply to every matched child.
Flex Preview Sample flex items using the selected layout values. Wrapping, spacing, cross-axis alignment, and visible overflow at a realistic item count.
Property Ledger Each emitted property, value, and note. Warnings such as align-content having no visible effect before wrapping creates multiple lines.
HTML Scaffold Starter wrapper and child markup based on simple class or ID selectors. Whether the real markup uses the same direct-child relationship.
JSON Normalized settings, generated CSS, generated HTML, ledger rows, preview items, and warnings. Whether another workflow expects the same selector, child suffix, and item count.

Reverse directions and min-width: 0 deserve deliberate review. Reverse values change visual order without changing source order, and min-width: 0 can fix row overflow by allowing long flex items to shrink inside the line.

Technical Details:

A flex container establishes a flex formatting context for its direct children. The container decides whether it is block-level or inline-level, which direction becomes the main axis, whether children stay on one line, how remaining space is distributed, and how children align on the cross axis. The children remain normal document content, so source order, focus order, intrinsic size, and overflow rules still matter.

The generated container rule always includes display, flex-direction, flex-wrap, justify-content, align-items, align-content, and gap. The optional child rule adds a direct-child selector with flex: grow shrink basis, plus min-width: 0 when that overflow fix is enabled.

Container rule core:

Flexbox container properties emitted by the generator
Property Layout role Supported values here
display Creates a block-level or inline flex container. flex, inline-flex
flex-direction Sets the main axis and visual flow direction. row, row-reverse, column, column-reverse
flex-wrap Controls whether items stay on one line or form additional flex lines. nowrap, wrap, wrap-reverse
justify-content Distributes the item group along the main axis. flex-start, flex-end, center, space-between, space-around, space-evenly
align-items Aligns items on the cross axis inside each flex line. stretch, flex-start, flex-end, center, baseline
align-content Distributes multiple flex lines on the cross axis. stretch, flex-start, flex-end, center, space-between, space-around, space-evenly
gap Adds space between adjacent flex items and between wrapped lines. 0 to 999 using px, rem, em, or %

Child sizing core:

Flex child sizing values emitted by the generator
Child rule part Accepted value Effect on layout
flex-grow Whole number from 0 to 12 0 prevents the item from taking extra main-axis space; larger values share positive space in proportion.
flex-shrink Whole number from 0 to 12 0 resists shrinking; positive values allow contraction when the line is tight.
flex-basis auto, content, min-content, max-content, fit-content, 0, or a supported length Sets the starting main-axis size before grow and shrink are resolved.
min-width: 0 Optional declaration in the child rule Lets row-based flex items with long content shrink instead of preserving their intrinsic minimum width.

For wrapped containers, align-items and align-content solve different problems. align-items aligns items within each flex line. align-content distributes the lines as a group, so it has no visible effect when wrapping is off or when the current children still fit on one line.

Selector text and child selector suffixes are trimmed to practical lengths, option values fall back to supported defaults, gap values are clamped from 0 to 999, preview item count is clamped from 2 to 12, and unsupported Flex basis text normalizes to auto. These checks keep the generated CSS usable, but they do not confirm that the selector targets the right element in your project.

Limitations and Privacy Notes:

The preview uses sample items and a controlled container, so it cannot know the real widths, images, form controls, nested blocks, or inherited styles in your project. Treat the generated CSS as a layout starting point and test it with the real component at narrow, medium, and wide widths.

Reverse direction values change visual order without changing source order. That can be useful for a visual treatment, but it should not be used to repair markup order for keyboard navigation, screen reader reading order, or logical copy-paste order.

No server request is needed to generate the CSS, preview, property ledger, starter HTML, JSON, copy actions, or downloads. The selector text and layout choices are still present in copied or downloaded artifacts, so avoid private project names if those files will leave your working environment.

Worked Examples:

Card footer actions

A footer with actions on the right can use .card-actions, flex, row, wrap, flex-end, center, and a 12px gap. The summary should report a horizontal main axis, and Flex CSS should contain only the container rule unless Include child sizing rule is enabled.

Responsive filter chips

A chip group can use .filter-chips, row, wrap, flex-start, baseline, and a 0.5rem gap. Increase Preview items until the preview wraps, then check that Property Ledger describes gap as spacing between adjacent items rather than outer margins.

Vertical sidebar stack

A sidebar group can use .sidebar-stack, column, nowrap, center, and stretch. The summary badge should report a vertical main axis, which means justify-content moves the group up or down inside the column.

Long-label overflow fix

When a long label pushes a row wider than expected, enable Include child sizing rule, keep Flex shrink at 1, use auto or a supported length such as 12rem for Flex basis, and turn on Set min-width: 0. Property Ledger should then include the child min-width row.

Advanced Tips:

  • Use wrap for filter chips, action groups, and responsive rows where cramped one-line overflow would be worse than a second line.
  • Use nowrap only when horizontal compression is intentional, then test long labels and narrow widths carefully.
  • Keep Align content at stretch unless the preview or real component has multiple flex lines with extra cross-axis space to distribute.
  • Turn on Set min-width: 0 for row-based children that contain long text, inputs, or nested blocks that refuse to shrink.
  • Use a simple class or ID selector when you want HTML Scaffold to mirror your intended wrapper instead of falling back to generic starter markup.
  • Download the Property Ledger CSV or DOCX when a review needs the reason for each declaration, not just the final CSS.

FAQ:

Why does justify-content move vertically sometimes?

justify-content always follows the main axis. With row, the main axis is horizontal. With column, the main axis is vertical.

Why did align-content not change anything?

align-content affects spacing between flex lines. It will not show a visible change when Wrap is nowrap or when the current items still fit on one line.

What Flex basis values are accepted?

Flex basis accepts auto, content, min-content, max-content, fit-content, 0, or a length using px, rem, em, %, ch, vw, vh, vmin, or vmax.

Should I use row-reverse or column-reverse?

Use reverse values only when the visual order is intentionally different from source order. The generated CSS can reverse the flow, but it does not rewrite the markup order used by keyboards, screen readers, and copy-paste.

Is the layout data sent to a server?

No server request is needed to build the CSS, preview, property ledger, scaffold, JSON payload, copy actions, or downloads. Those outputs are produced in the browser page.

Glossary:

Flex container
The element that receives display: flex or display: inline-flex.
Flex item
A direct child of a flex container.
Main axis
The direction set by flex-direction; justify-content distributes space along it.
Cross axis
The perpendicular direction used by align-items and multi-line align-content.
Flex line
A row or column of flex items; wrapping can create more than one line.
Flex basis
The starting main-axis size used before flex grow and flex shrink are resolved.

References: