ToolKun
CategoriesAbout Us
ToolKun

All-in-one online tool platform providing various useful tools to boost your productivity.

Quick Links

  • All Tools
  • Categories
  • Latest Tools
  • Tutorials

Support

  • Help Center
  • Contact Us
  • Feedback
  • About Us
  • Privacy Policy
  • Terms of Service
  • Sitemap
  • Gemini Watermark Remover

© 2026 ToolKun. All rights reserved.

Made with ❤️ for developers and creators

CSS Grid Generator - Grid Layout Visual Tool

Visually create CSS Grid layouts

Visual editing
Live preview
Code generation
Custom sizes
Layout Settings
3
3
Preview
1
2
3
4
5
6
7
8
9
CSS
.container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 16px;
}
HTML
<div class="container">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
  <div class="item">6</div>
  <div class="item">7</div>
  <div class="item">8</div>
  <div class="item">9</div>
</div>

CSS Grid Generator helps you quickly create two-dimensional grid layouts. Set columns, rows, and gaps through an intuitive control panel, customize each column and row size (supports fr, px, % and more). Preview layout in real-time, and get automatically generated CSS and HTML code ready to copy and use.

Core Grid Layout Concepts

CSS Grid is a powerful 2D layout system. grid-template-columns defines column structure, grid-template-rows defines row structure. The fr unit represents fractions of remaining space (e.g., 1fr 2fr means 1:2 distribution), auto adjusts to content, fixed values like 200px. gap sets row and column spacing uniformly.

Size Unit Comparison

  • fr (fraction): Distribute remaining space proportionally, e.g., 1fr 1fr 1fr for 3 equal columns
  • auto: Adjust based on content, common for navigation items
  • px/em/rem: Fixed sizes, good for sidebars and fixed-width elements
  • minmax(min, max): Set size range, essential for responsive layouts

Responsive Grid Layout Tips

Use repeat(auto-fit, minmax(250px, 1fr)) to create adaptive column counts: more columns when wide, fewer when narrow. Combined with gap and media queries, easily achieve responsive card layouts.

FAQ

Q: Should I use Grid or Flexbox?

A: Grid is ideal for 2D layouts (controlling both rows and columns), like overall page structure, card grids, and complex forms. Flexbox is better for 1D layouts (single row or column), like navigation menus and button groups. They can be combined.

Q: What are implicit and explicit grids?

A: Explicit grid is defined via grid-template-columns/rows. When content exceeds the defined range, Grid automatically creates implicit tracks. Use grid-auto-rows/columns to control implicit track sizes.

Q: How to make an element span multiple rows or columns?

A: Use grid-column: span 2 (span 2 columns) or grid-row: 1 / 3 (from row 1 to row 3). You can also use grid-area to specify start/end positions: grid-area: 1 / 1 / 3 / 4 (row-start / col-start / row-end / col-end).