Fix stubborn layouts with a flexbox and grid playground in 2026

Pull the layout out of your app and into a visual playground. Change properties until the boxes behave, then copy the CSS back. This beats editing blind in DevTools because your changes don't vanish on reload and you can tweak each child on its own. Skip it when the bug comes from real content or inherited styles, because generic boxes won't reproduce those.

The flexbox and grid playground I link to below is one I built. Before writing it I tried five other playgrounds. Most of them handled the container well and treated the children as an afterthought, and the children are where my layout bugs usually live. It's free, runs client-side, and needs no signup or upload. If you have a better one, tell me and I'll happily switch.

The layout bug that ate my afternoon

Back in March 2026 I was rebuilding a pricing page. It had three cards in a row, with the middle one a bit wider. Every card had its "Choose plan" button pinned to the bottom so the buttons lined up no matter how much copy sat above them. Standard stuff. I've built that layout maybe a dozen times.

It took me 47 minutes.

The buttons wouldn't line up. Each card was a column flex container with margin-top: auto on the button. That's the textbook trick, and it did nothing. So I did what everyone does. I opened DevTools, clicked the little flex badge, and started toggling justify-content and align-items in the Styles pane. Some combinations got close. Then Vite hot-reloaded because I'd saved an unrelated file, and every tweak I'd made in the browser was gone. That happened twice before I started copying values into a scratch file by hand. It's a sad way to spend a Tuesday afternoon.

The actual bug was on line 238 of pricing.css: align-items: center on the row that held the cards. Centering the cards on the cross axis meant they stopped stretching to equal height. Each card was only as tall as its own content, so the auto margin on the button had zero free space to eat. I removed one declaration and everything snapped into place.

Here's what bugged me afterwards. I know what align-items does. I could recite its default (stretch) if you asked. What I couldn't do was keep the interaction between a parent's cross-axis alignment and a child's auto margin in my head while I stared at a 400-line stylesheet full of other people's decisions. Flexbox and grid properties are easy one at a time. They get hard in combination, and most docs teach them one at a time.

What I wanted was a blank room: a container with a few children in it, where every property on both levels had a control and the preview updated as I clicked. I'd reproduce the shape of the bug with dumb boxes, find the property that breaks it, then go back to the real code knowing what to look for.

How a layout playground works under the hood

There's nothing magic in here. I think that's worth saying, because it changes how you use the tool. A playground like this keeps one piece of state: the container's properties plus an array of per-item overrides. Every dropdown and slider writes into that state. The preview is a set of DOM nodes with that state applied as styles. The CSS panel is the same state serialized to text. Because the preview and the output come from one source, what you see is literally what you copy.

Here's a stripped-down serializer you can run with Node. It's the core idea without any UI:

// layout-to-css.js // Run with: node layout-to-css.js const container = { display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "stretch", gap: "16px", }; // Per-item overrides, the same shape a playground keeps when you click an item const items = [ { flexGrow: 1, flexBasis: "220px" }, { flexGrow: 2, flexBasis: "220px", alignSelf: "flex-start" }, { flexGrow: 1, flexBasis: "220px", order: -1 }, ]; const toKebab = (prop) => prop.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()); function toRule(selector, props) { const body = Object.entries(props) .map(([prop, value]) => ` ${toKebab(prop)}: ${value};`) .join("\n"); return `${selector} {\n${body}\n}`; } const css = [ toRule(".container", container), ...items.map((props, i) => toRule(`.item:nth-child(${i + 1})`, props)), ].join("\n\n"); console.log(css); /* Output: .container { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: stretch; gap: 16px; } .item:nth-child(1) { flex-grow: 1; flex-basis: 220px; } .item:nth-child(2) { flex-grow: 2; flex-basis: 220px; align-self: flex-start; } .item:nth-child(3) { flex-grow: 1; flex-basis: 220px; order: -1; } */ 

Notice align-items: stretch in there. It's the default, and a smarter generator would leave it out so you don't paste noise into your codebase. I left it in on purpose, because that one line is the whole pricing-page bug. A generator could also offer the flex shorthand, though I go back and forth on that. flex: 1 expands to 1 1 0%, which surprises people who expected the basis to be auto.

Grid mode works the same way. The container holds the track templates and gap, and each item can carry something like grid-column: span 2. The serializer doesn't care which layout model it's printing.

If you'd rather click than edit a config object, the CSS Flexbox & Grid Playground wraps exactly this loop in visual controls. You switch between flex and grid, add or remove items, and select one item to give it its own flex-grow or align-self. When the preview looks right, you copy the CSS. For my pricing page, flipping align-items between stretch and center in a sandbox would have shown me the cards losing their shared height long before I found line 238.

How it compares to DevTools and the classics

I use all of these, and none of them replaces the others.

Tool Best for Works on your real page Per-item controls Copy-ready CSS
CSS Flexbox & Grid Playground Isolating a layout behavior so you understand it No, it's a sandbox Yes, select any item Yes, copy the generated CSS
Chrome DevTools flex/grid editors Debugging the page that's actually broken Yes Through the Styles pane, by hand No, you copy declarations manually
Firefox layout panel Seeing grid lines and named areas overlaid Yes Through the rules view No
Flexbox Froggy / Grid Garden Learning property names for the first time No Only what each level asks for No
CodePen Sharing a reproduction with a teammate No You write it yourself It's already your code

Honestly, the Firefox grid inspector is still the best thing I've seen for understanding named areas and line numbers on a real page. I'm not going to pretend a sandbox beats it there.

My split works like this. I use DevTools when the bug only exists on the real page, and a playground when I need to understand why a behavior happens. CodePen comes in once someone else needs to see it. Froggy and Grid Garden are for the week you're learning. They're great at that job, but once you know the property names you'll outgrow them.

When not to reach for a playground

A sandbox only helps if the bug survives the trip into it. Plenty of bugs don't.

Content-driven bugs. Three weeks ago a teammate pinged me about a sidebar that blew out of its grid column on one specific page. In the playground it looked perfect, and that turned out to be the clue. The page had a 90-character URL with no break opportunities. Grid items default to min-width: auto, so they refuse to shrink below their content. The fix was min-width: 0 on the item (or minmax(0, 1fr) instead of 1fr on the track). Generic boxes labeled "Item 2" never contain long URLs, so they'll never show you this.

Inherited and global styles. If a component library or an old utility class is quietly setting width or flex on your elements, the playground can't know about it. The Computed tab in DevTools will tell you in seconds.

Visual order versus source order. A playground makes order and row-reverse feel cheap: change a number and the card moves. Keyboard focus and screen readers follow the DOM, though, so a layout that looks right can tab through items in a confusing sequence. Yes, my code sample above uses order: -1. That's fine in a demo. In a real component, reaching for order usually means the markup should change instead.

Utility-first codebases. The output is plain CSS. If your project uses Tailwind, you'll be translating justify-content: space-between to justify-between by hand. For a small layout it's often faster to edit the classes in the browser directly.

Things I'm not sure about. Subgrid is the one I keep circling. Every major browser ships it now, and it solves the "align buttons across sibling cards" problem more cleanly than my flex trick did. But I haven't found a sandbox (any sandbox) that makes nested grid tracks click for me the way a real page does. Maybe that's a gap in the tools, or maybe it's a gap in my head. I genuinely don't know yet.

FAQ

Q: Should I use flexbox or grid?

A: Use flexbox when you're laying things out in one direction and want content size to drive spacing, like a nav bar or a row of tags. Use grid when you're defining rows and columns up front and placing things into them. For my pricing cards, grid with subgrid would arguably have been the better call. I picked flex out of habit.

Q: Does the playground send my CSS anywhere?

A: No. It runs in your browser, there's no account, and you don't upload anything.

Q: Why won't my flex item shrink?

A: It's almost always min-width: auto. Flex and grid items won't shrink below their content's minimum size unless you set min-width: 0 (or min-height: 0 in a column). It catches everyone, me included, about twice a year.

Q: Can I paste the generated CSS straight into production?

A: You can, but map it onto your real selectors first. Playground output is written against demo class names, which are fine for a test and confusing in a real component. Treat it as a correct set of declarations, then move them where they belong.

Written with AI assistance and human review. Try the tool at aidevhub.io/flexbox-playground.