Flexbox and CSS Layout Generator
Build a flexbox row, column or wrapping list of cards by choosing direction, wrap, justify, align and gap, and watch the preview update as you go. Copy the CSS, matching HTML and Tailwind classes. A quick grid tab covers simple fixed grids; for responsive layouts with named areas, use the CSS Grid Generator. Everything runs in your browser. Nothing you type or paste is sent to We.Inc or anyone else.
How it works
- Choose the Grid tab and set how many columns and rows you need.
- Give each column and row a size: a fraction (1fr), a fixed width (240px), auto, or a minmax() range such as minmax(200px, 1fr).
- Set the column and row gaps.
- Type an area name, then click or drag across cells in the preview to assign them to that area. Areas must be rectangles; the tool warns you if one is not.
- Copy the CSS (grid-template-columns, grid-template-rows and grid-template-areas), the HTML skeleton and the Tailwind classes.
- For a single row or a wrapping list of cards, switch to the Flexbox tab and pick direction, wrap, justify, align, gap and item count.
A page shell in four lines of CSS
The classic layout of header on top, sidebar and main in the middle and footer at the bottom is two columns and three rows. With columns set to 240px 1fr and rows set to auto 1fr auto, the areas read: "header header" "sidebar main" "footer footer". Load the example to see it, then change the sidebar width or add a column for a right-hand panel.
Because the layout lives in the parent, you can rearrange it for small screens in a media query by redefining grid-template-areas with one column, without touching the HTML order.
When the preview and your site do not match
If the layout collapses on your site, check that every child has the grid-area name that appears in the template, that the parent has display: grid, and that no area is L-shaped. A misspelt area name makes the child fall into the next free cell instead.
Content wider than its track (a long word or a wide image) can push a 1fr column wider than you expect. minmax(0, 1fr) instead of 1fr lets the column shrink below its content width.
Tips
- Use fr units for columns that should share space, and px or minmax() for sidebars that should not shrink below a readable width.
- Name areas after what they hold (header, nav, main, aside, footer). The CSS then reads like a sketch of the page.
- grid-template-areas must form rectangles. An L-shaped area is invalid and the browser ignores the whole property.
- For a responsive card grid without media queries, use repeat(auto-fill, minmax(240px, 1fr)) as the column value.
- Grid is for two-dimensional layouts (rows and columns together). Flexbox is simpler for a single row or column, such as a nav bar.
- Tailwind has no built-in class for named areas, so the tool gives you arbitrary-value classes such as [grid-template-areas:...] where needed.
Frequently asked questions
What does a CSS grid generator do?
It writes the grid-template-columns, grid-template-rows, gap and grid-template-areas CSS for the layout you set visually, so you do not have to count tracks by hand. You copy the CSS and HTML into your own site.
What is the difference between fr, auto and minmax?
1fr takes one share of the leftover space. auto sizes the track to its content. minmax(200px, 1fr) keeps a track at least 200px wide but lets it grow to one share. Fixed px values never change.
How do grid-template-areas work?
Each quoted string is one row, and each word in it is one column. Repeating a name across cells stretches that area over them. A dot (.) leaves a cell empty. Each child element then uses grid-area: name to go into its area.
Does the Tailwind output work without custom config?
Yes. Column and row templates become arbitrary values such as grid-cols-[240px_1fr], and named areas become [grid-template-areas:...] plus [grid-area:name] on each child. These work in Tailwind v3 and v4 with no plugin.
Should I use grid or flexbox?
Use grid when you care about both rows and columns lining up, such as a page shell or a gallery. Use flexbox for one direction, such as a row of buttons or a nav bar. They are often combined: a grid page with flex rows inside.
Can I build a whole website this way?
You can hand-code one. If you would rather not write CSS, We.Inc builds and hosts a site for you from a description. Building a site on We.Inc is free for every account, with no card needed. Paid plans are Starter at $20 a month (AI building and custom domains), Pro at $49 and Max at $99.
Related: CSS Grid Generator (responsive, Tailwind, React), CSS Shadow Generator, HTML Table Generator, Website Mockup Generator, Website builder, Landing page templates, Pricing.
Turn this result into your website or see the We.Inc website builder. Building a site on We.Inc is free, with no card needed to start. Paid plans are Starter at $20 a month, Pro at $49 and Max at $99. See pricing.
More in Free Tools
- CSS Minifier
- CSS Box Shadow Generator
- CSS Specificity Calculator
- CSS Text Shadow Generator
- CSS to Tailwind Converter, Both Directions
- CSS Tooltip Generator
- CSS Triangle Generator
- CSS Wave Generator
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App