CSS Gradient Generator
Build linear, radial and conic gradients and copy the CSS.
Design & SEO
Build CSS Flexbox and Grid layouts visually and copy the code.
The rule that actually holds: Flexbox for one dimension, Grid for two.
Flexbox lays items along a single axis and lets them size themselves. Reach for it when you have a row of things whose widths depend on their content — a navigation bar, a button group, a card footer, anything centered.
Grid defines a two-dimensional structure that items are placed into. Reach for it when the layout exists independently of the content — a page skeleton, a photo grid, a dashboard, a form with aligned label and field columns.
| You want | Use | Why |
|---|---|---|
| Center one thing | Grid + place-items:center | Two properties, works every time |
| A navigation bar | Flexbox | Items size to their content |
| Equal-width columns | Grid | fr units divide space exactly |
| A responsive card grid | Grid + auto-fit + minmax | Reflows with no media queries at all |
| A sticky footer | Flexbox column | flex:1 on the main region |
| Sidebar plus content | Grid | Named areas make it readable |
| A tag or chip list | Flexbox + wrap | Variable widths, natural wrapping |
| Overlapping elements | Grid | Place both in the same cell |
This one line replaces most of the breakpoint code in a typical stylesheet:
grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
It means: fit as many columns as will hold at least 272px, and let them share the leftover space equally. At 1200px you get four columns, at 800px three, at 560px two, at 320px one — with no breakpoints written anywhere.
The difference between auto-fit and auto-fill catches everyone once. With two items in a wide container, auto-fit stretches them to fill the row; auto-fill keeps them at their minimum and leaves empty tracks. Use auto-fit unless you specifically want the column rhythm preserved.
The names describe axes, not directions, and the axes swap depending on flex-direction. That is the whole source of the confusion.
In Flexbox, justify-content works along the main axis and align-items across the cross axis. With flex-direction: row the main axis is horizontal, so justify-content moves things left and right. Switch to column and the same property now moves them up and down.
Grid is more predictable because both axes always exist: justify-* is inline (horizontal in English), align-* is block (vertical). The shorthands place-items and place-content set both at once, which is why place-items: center is the shortest reliable centering in CSS.
The gap property works in both, and replaced the margin-based spacing hacks entirely — it applies only between items, never at the edges.
min-width: auto stops it. Add min-width: 0 — this is why long text overflows a flex container instead of ellipsising.flex: 1 is not flex-grow: 1. The shorthand also sets flex-basis: 0, which makes items equal width regardless of content. That is usually what you wanted, but not always.margin-left: auto on one flex item pushes it and everything after it to the end — often cleaner than restructuring the container.On the parent: display:grid; place-items:center. Two properties, works in every browser, and does not depend on the child having a known size.
Flexbox for one dimension where content decides the sizes; Grid for two dimensions where the layout is defined independently of content. They compose well — Grid for the page, Flexbox inside components.
With fewer items than fit, auto-fit stretches them to fill the row while auto-fill keeps them at their minimum and leaves empty tracks.
The default min-width:auto prevents shrinking below the content size. Set min-width:0 on the item.
Yes, in every browser since 2017. Subgrid is newer — all major engines shipped it during 2023–24 — so check if you need that specifically.
Yes, in every current browser. It replaced the negative-margin spacing hacks entirely.
No. It is plain CSS with no dependency, ready to paste into any stylesheet.