Developer Tools
Flexbox & CSS Grid Generator
Build flexbox and CSS grid layouts visually — direction, wrap, alignment, gap, columns and rows — and copy the CSS or Tailwind classes.
How to use
- 1Choose Flexbox or Grid and set the container options.
- 2Watch the preview update, then copy the CSS or Tailwind classes.
Frequently asked questions
Flexbox or grid — which should I use?
Flexbox for one-dimensional rows or columns (navbars, button groups); grid for two-dimensional layouts (cards, page structure).
What does justify-content do?
It aligns items along the main axis — horizontally in a row.
What does fr mean in grid?
A fraction of the free space: 1fr 2fr gives the second column twice the width of the first.
Flexbox and grid solve different shaped problems
Flexbox lays items along one axis — a row or a column — and is the right tool when content decides the size: a nav bar that should center its links, a row of buttons that needs to wrap on narrow screens, a card footer where one action should push to the far right. Grid defines both axes at once with grid-template-columns and grid-template-rows, so it fits layouts where the structure comes first: a page shell with a fixed sidebar and fluid content, or a gallery where every tile should line up in both directions. Reaching for grid to center one button, or flexbox to build a 12-column page layout, usually ends in extra wrapper divs to fake the other axis.
The preset buttons are doing real pattern-matching, not just filling the input
The grid-template-columns field is a plain text input, so anything valid CSS accepts works — fixed widths, fr units, minmax(), repeat(). The five preset pills just write a known string into that field. Worth knowing: the Tailwind-class output only recognizes the literal pattern repeat(N, 1fr) and converts it to grid-cols-N; anything else, including the auto-fill preset, falls through to an arbitrary-value class like grid-cols-[repeat(auto-fill,_minmax(120px,_1fr))]. That's correct Tailwind syntax, but it's a sign you're outside Tailwind's named scale and should check the class actually compiles in your project's Tailwind config (arbitrary values need the JIT engine, which is default in v3+).
Worked example: a responsive card grid
Switch to Grid, click the repeat(auto-fill, minmax(120px, 1fr)) preset, and leave gap at 12px. The preview immediately reflows the numbered boxes into as many 120px-minimum columns as fit the container, growing them evenly to fill leftover space — no media query needed. The generated CSS reads exactly: display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); grid-template-rows: auto; justify-items: stretch; align-items: stretch; gap: 12px. The Tailwind output, per the rule above, becomes grid grid-cols-[repeat(auto-fill,_minmax(120px,_1fr))] justify-items-stretch items-stretch gap-3 — gap-3 because 12px is 3 × 4px, Tailwind's spacing unit.
auto-fill versus auto-fit, a one-word difference with a visible effect
Both keywords let grid-template-columns create as many tracks as fit the container, but they diverge the moment there isn't enough content to fill every column: auto-fill keeps the empty tracks in place (so with only 2 items and room for 4 columns, you get 2 cards and 2 blank gaps), while auto-fit collapses the empty tracks to zero width and lets the existing cards stretch to fill the freed space. Swapping one keyword for the other in an otherwise identical grid-template-columns value is the entire difference between a layout with visible trailing gaps and one where cards grow to fill the row — worth testing with a realistic, possibly-short list of items, not just the playground's fixed preview boxes.
Why justify-content and align-items aren't interchangeable in flex
In a flex row, justify-content controls spacing along the main axis (horizontal, by default) while align-items controls position along the cross axis (vertical) — set flex-direction to column and the two swap which direction they each govern, since the main axis itself has rotated. Mixing them up is the most common reason a 'centering doesn't work' bug persists after setting the wrong one of the two properties; the playground's live preview is useful specifically because it makes that axis-swap visible immediately when direction changes, rather than requiring a mental model of which axis is 'main' at any given moment.
Related tools
- Big-O Complexity Cheat Sheet
Time and space complexity of common data structures and sorting algorithms — average and worst cases in Big-O notation.
- Git Commands Cheat Sheet
The Git commands you actually need — setup, branching, undoing mistakes, stashing, rebasing and working with remotes — with what each does.
- HTTP Status Codes
Look up every HTTP status code — 200, 301, 404, 429, 502 and more — with what it means and when servers send it.
- Online HTML, CSS & JS Editor (Live Preview)
Write HTML, CSS and JavaScript and see the result instantly — live preview, console, templates, shareable links and one-click HTML download. Like CodePen, with nothing to sign up for.
- Photo Collage Maker (Grid, Side-by-Side, Sprite Sheet)
Combine photos into a collage or grid, place two images side by side or stacked, or pack sprites into a sprite sheet — with spacing, background and size options.
- Social Media Image & Video Size Guide
Current recommended image and video sizes for Instagram, Facebook, X, LinkedIn, TikTok, YouTube and Pinterest — posts, stories, covers, thumbnails and ads.