CSS Layout Playground

Build Flexbox and Grid layouts visually and copy the generated code.

Presets:

Container

Items (3)

Item 1
Item 2
Item 3

Preview

1
2
3

Generated Code

CSS
.container {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 8px;
}

.item {
  min-width: 60px;
  min-height: 60px;
}

.item-1 {
  flex-grow: 0;
  flex-shrink: 1;
  flex-basis: auto;
}

.item-2 {
  flex-grow: 0;
  flex-shrink: 1;
  flex-basis: auto;
}

.item-3 {
  flex-grow: 0;
  flex-shrink: 1;
  flex-basis: auto;
}
HTML
<div class="container">
  <div class="item item-1">Item 1</div>
  <div class="item item-2">Item 2</div>
  <div class="item item-3">Item 3</div>
</div>

About This Tool

How to Use
  1. Choose Flexbox or Grid mode, or start from a preset
  2. Adjust container properties (direction, wrap, justify, align, gap, grid templates, grid-auto-flow, align-content)
  3. Add or remove items and set their properties (flex-grow, flex-shrink, flex-basis, align-self, order, grid-column, grid-row)
  4. Copy the generated CSS and HTML code; it matches the preview, including the minimum item size
Common Use Cases
  • Learning CSS Flexbox and Grid layout visually
  • Quickly prototyping page layouts without writing code
  • Generating CSS code for common layout patterns
  • Teaching CSS layout concepts to students
Tips & Tricks
  • Start with a preset layout and modify it to learn how properties work
  • Use the gap property for consistent spacing between items
  • Grid's repeat() function is powerful for responsive layouts
  • Copy the generated code directly into your project

Related Tools