Flexbox: The Axes Swap (And That Is the Whole Trick)
Nearly every 'why is this not centring' question is the axis swap. justify-content works along the main axis and align-items across the cross axis, and flex-direction decides which is which.
Set the container and item properties. You get the CSS, a rendered preview, and both axes named for your direction.

Workflow Lifecycle & Pipeline
Visual execution flow showing how Flexbox Generator processes data directly in your local browser sandbox.
Flexbox Generator Interactive Process Pipeline
Fast, zero-latency execution directly in your browser memory.
Before You Start
Ensure your source assets and browser environment meet the verified execution requirements.
Step-by-Step Instructions
Follow these verified steps to execute the task with Flexbox Generator.
Enter flex-direction
Fill in flex-direction, justify-content (main axis) and align-items (cross axis), plus the 7 below. Each starts at a usable value, so you can change one and leave the rest.
flex-direction row · justify-content (main axis) flex-start · align-items (cross axis) stretch10 fields read as you typeWatch the result change
There is no button on Flexbox Generator: the result follows the input as you change it.
Updates as you typeFlexbox Generator runs on your deviceCopy the answer
The answer sits at the top of the result panel with a copy button beside it. It never left your browser.
Copy the figureOn your clipboardUnder the Hood: Sandboxed WASM Execution & Isolated Web Workers
Development tools and code sandboxes execute inside sandboxed Web Workers with isolated thread runtimes. Code scripts cannot access DOM scopes, cookies, or local network interfaces, providing high security and bare-metal performance.
Real-Time Stdin Stream
Interactive inputs pipe directly into std::cin, sys.stdin, and ReadLine buffers via simulated virtual teletypes.
Zero Egress Guarantee
Algorithm logic, API keys, and test queries remain confined to the client virtual machine.
Near-Native CPU Performance
Precompiled WebAssembly modules execute with near-native JIT performance on V8 and SpiderMonkey engines.
Settings & Options Explained
Fine-tune quality, format, and compression parameters for your exact workflow.
Settings & Configuration Guide
| Setting | Recommended Value | How It Works & Impact |
|---|---|---|
| flex-direction | row | Takes one of row, row-reverse, column or column-reverse. Impact: Each option is a different flex-direction; switching it changes the result, not the speed. |
| justify-content (main axis) | flex-start | Takes one of flex-start, flex-end, center, space-between, space-around or space-evenly. Impact: Each option is a different justify-content (main axis); switching it changes the result, not the speed. |
| align-items (cross axis) | stretch | Takes one of stretch, flex-start, flex-end, center or baseline. Impact: Each option is a different align-items (cross axis); switching it changes the result, not the speed. |
| flex-wrap | nowrap | Takes one of nowrap, wrap or wrap-reverse. Impact: Each option is a different flex-wrap; switching it changes the result, not the speed. |
| align-content (between wrapped lines) | normal | Takes one of normal, flex-start, flex-end, center, space-between, space-around or stretch. Impact: Each option is a different align-content (between wrapped lines); switching it changes the result, not the speed. |
| gap (px) | 16 | Takes a number from 0 to 100, in steps of 2. Impact: The control runs from 0 to 100; 100 is as far as it goes. |
Best Practices & Key Considerations
Avoid common quality pitfalls and maximize output performance.
Expert Recommendations
- In a row the main axis is horizontal, so justify-content centres left-to-right. In a column it becomes vertical, so justify-content centres top-to-bottom and align-items centres horizontally. Nothing is broken when that happens.
- A flex item's min-width defaults to auto, so it refuses to shrink below its content and overflows instead of shrinking. min-width: 0 is the fix, and it is the most useful piece of flexbox knowledge after the axis rule.
- flex: 1 is 1 1 0% — items share space equally whatever their content. flex: auto is 1 1 auto — items share only the leftover space, so a longer one stays wider. They look alike and behave differently.
- align-content positions wrapped LINES; align-items positions items within a line. On a single-line container align-content does nothing at all, which is why setting it so often seems broken.
- gap works in flexbox everywhere current and replaces the margin-on-every-child-but-the-last pattern. It applies between items only.
- Flexbox lines do not know about each other, so columns will not line up across wrapped rows. If they must, that is a grid.
Common Mistakes to Avoid
- Expecting gap (px) to go past 100 — 0 to 100 is the range the control offers.
- Expecting Items in the preview to go past 12 — 1 to 12 is the range the control offers.
- Leaving flex-direction on row when row-reverse or column was wanted.
- Assuming the input is sent somewhere — Flexbox Generator runs in this tab, and nothing you enter leaves it.
Troubleshooting & Fixes
Quick solutions for common browser constraints, format issues, and edge cases.
Troubleshooting & Common Issues
gap (px) will not go above 100
Possible Cause: The control runs from 0 to 100.
Items in the preview will not go above 12
Possible Cause: The control runs from 1 to 12.
The answer is right but not in the form you wanted
Possible Cause: flex-direction is set to row, and it decides that.
Frequently Asked Questions
Everything you need to know about formats, privacy, and browser support.
Related Step-by-Step Guides
Explore companion workflows, optimization techniques, and verified tutorials.