30 CSS Grid Layouts
30 CSS Grid Layouts for articles, docs pages, photo galleries, bento product sections, admin dashboards, pricing tables, and kanban boards — spanning holy-grail systems, RAM auto-fit and masonry walls, subgrid-aligned cards, container-query components, and scroll-snap sliders. Scoped under .cgl-NN for no-collision pasting, prefers-reduced-motion guarded, framework-agnostic.
Related20 CSS Container Queries15 CSS Flexbox Layouts15 CSS Card Grid Layouts30 CSS Sidebar Layouts
Course pickPartner: Zero to Mastery
Affiliate linkWant to build responsive CSS Grid layouts from scratch?
You just browsed 30 layouts. Learn Grid properly: templates, named areas, placement and alignment, so every layout starts in your head, not in a copy-paste.
Every ZTM course in one membership: $25/month, paid yearly at $299 · 30‑day money-back guarantee
Fundamentals of CSS Grid. We may earn a commission, at no extra cost to you.
02. Sticky Sidebar Grid (opens in a new tab)
03. Responsive Media Gallery (opens in a new tab)
<figure> elements — the markup search engines and screen readers want.04. Modern Holy Grail (opens in a new tab)
05. Dynamic Data Grid (opens in a new tab)
<table> styling pain.06. Card Stack Overlay (opens in a new tab)
07. Holy Grail (opens in a new tab)
08. 12-Column Grid (opens in a new tab)
09. Bento Box (opens in a new tab)
10. Magazine Editorial (opens in a new tab)
11. RAM Auto-Fit (opens in a new tab)
12. Quantity Query (opens in a new tab)
13. Pinterest Masonry (opens in a new tab)
14. Hexagonal Honeycomb (opens in a new tab)
15. Subgrid Card (opens in a new tab)
16. Dashboard Skeleton (opens in a new tab)
17. Pricing Table (opens in a new tab)
18. Kanban Board (opens in a new tab)
19. Aspect-Ratio Tiles (opens in a new tab)
20. Container-Query Card (opens in a new tab)
21. Diagonal Skew Grid (opens in a new tab)
22. Asymmetric Splash (opens in a new tab)
23. Mosaic Photo Wall (opens in a new tab)
24. Dense Packing (opens in a new tab)
25. Numbered Steps Track (opens in a new tab)
<ol> underneath, as the semantics demand.26. Mac App Sidebar (opens in a new tab)
27. Scroll-Snap Slider (opens in a new tab)
28. Aurora Map (opens in a new tab)
29. Logo Wall (opens in a new tab)
30. Periodic Table (opens in a new tab)
Build your own
Tweak the exact look in our visual generators — no signup, instant copy-paste.
Frequently asked questions
What is a CSS grid layout and when should I reach for one?
display: grid to position elements in two dimensions — rows and columns at the same time — using explicit tracks (grid-template-columns: 1fr 2fr 1fr), named areas (grid-template-areas), or auto-flowing patterns (repeat(auto-fit, minmax(240px, 1fr))). Reach for grid whenever your layout needs alignment across BOTH axes at once: a page shell with header / sidebar / main / footer, a card gallery that reflows across breakpoints, a magazine-style asymmetric editorial spread, a kanban board with fixed-height columns and free-height cards, a pricing table with tier-aligned features, a data dashboard whose widgets snap to a shared grid. Every demo in this collection is graded on four axes tier-1 (US/UK/CA/AU/NZ) devs actually care about: (1) MODERN CSS — subgrid, container queries, :has() quantity queries, aspect-ratio, min()/clamp() intrinsic sizing, grid-auto-flow: dense, oklch()/color-mix() palettes, logical properties for RTL. (2) SEMANTIC + ACCESSIBLE — every layout is real landmarks (<header>/<nav>/<main>/<aside>/<footer>) with <article> for cards and heading order preserved, focus-visible rings, 44px+ touch targets, prefers-reduced-motion guarded. (3) INTRINSIC SIZING — minmax(), min(), clamp(), fit-content replace hardcoded pixel widths so layouts survive any content length. (4) DROP-IN PORTABILITY — every demo scoped under .cgl-NN with tokenized colors so you can retune the palette by changing 3-6 CSS custom properties without touching layout math.When should I use CSS grid instead of flexbox?
How do I ship a SaaS dashboard layout with CSS grid (Linear / Notion / Vercel style)?
grid-template-columns: repeat(12, 1fr) for the widget rail, and each widget spans grid-column: span N where N maps to its width tier — a KPI tile is span 3, a chart is span 6, a full-width activity feed is span 12. Widgets place with grid-auto-flow: dense so smaller tiles backfill holes when the layout wraps on medium screens. For the sidebar-nav shell wrap that outer widget grid in a two-column parent: grid-template-columns: 240px 1fr for the sidebar + main split, with @media (max-width: 768px) { grid-template-columns: 1fr; } to collapse the sidebar to a drawer on mobile. Linear, Notion, Vercel, Figma, Stripe Dashboard, and Airtable all ship variants of this exact recipe. Widget contents use nested flexbox for the label + value + delta arrangement so text metrics align across widgets.How do I do a Pinterest / masonry layout in pure CSS without JavaScript?
columns: 4 200px; column-gap: 12px; on a container and each item break-inside: avoid — which is Baseline everywhere and works today. Items fill top-to-bottom, then left-to-right (reading order breaks if that matters — check with a screen reader). (2) The newer grid-template-rows: masonry (Firefox has it behind a flag; Chrome + Safari have it as grid-template-rows: masonry in draft) — better reading order preservation but not Baseline-safe yet, so the demo ships CSS columns as the production path with a commented-out masonry rule as the forward-compat opt-in. For the CSS columns approach, if you need reading order to match visual order (accessibility + SEO signal for a portfolio), you have to reorder the DOM to match how columns pack items, which is exactly the trade-off masonry-grid was supposed to solve. Pinterest itself uses a JS-driven layout for exactly this reason; a CSS-only masonry is a good fit when reading order can be visual-column-major (photo galleries, illustration portfolios, mood boards).How do I use CSS subgrid for aligned card content?
grid-template-rows: auto 1fr auto (title / body / footer tracks), and each CARD sets display: grid; grid-template-rows: subgrid; grid-row: span 3 — which makes the card's INNER rows lock onto the OUTER grid's row tracks. Every card's title-row aligns with every other card's title-row; body-rows flex together; footer-rows anchor at the same y-coordinate. Baseline widely-available (Chrome 117+, Safari 16+, Firefox 71+). This is the pattern shadcn card grids, Linear dashboard tiles, and every serious pricing table converges on — before subgrid, you'd either hardcode heights (broke on i18n) or use JS to measure and equalize (broke on hydration).How do I ship an e-commerce product grid (Shopify / Amazon / Stripe checkout)?
repeat(auto-fit, minmax(240px, 1fr)) grid that wraps at any container width without media queries. For a full e-commerce product grid you'd nest inside each grid cell: an aspect-ratio: 4/5 media wrapper (product image), a title + price row (flex row with justify-content: space-between), a badge column (Sale / New / Bestseller), and a hover Add-to-Cart CTA that appears via :has(:hover). Shopify Dawn, WooCommerce Storefront, BigCommerce Stencil, Amazon product tiles, and Stripe Checkout item lists all use variants of this pattern. Combine with Demo 12 (Quantity Query) to change the visual density based on how many products are on screen: ul:has(> li:nth-child(4)) switches to a 4-column layout only when 4+ products exist; smaller counts get bigger tiles. This is the modern replacement for the JS-driven 'if fewer than 4 items, use different template' logic every e-commerce theme used to ship.How do I make a CSS grid layout RTL-ready for Arabic / Hebrew / Persian?
margin-left, padding-right, left: 0, border-right-width. Logical: margin-inline-start, padding-inline-end, inset-inline-start: 0, border-inline-end-width. Grid tracks: use grid-column: 1 / -1 for spanning (works in both directions) instead of grid-column-start: 1. Sizing: inline-size / block-size instead of width / height when you're expressing 'the reading direction' vs 'the block direction' (they map to width/height in LTR and swap in RTL). Padding: padding-block and padding-inline. Set dir='rtl' on the root and the entire layout mirrors automatically — no per-selector overrides needed. The one gotcha: transform-based decorations (translate, rotate) don't auto-flip; wrap those in @media (dir: rtl) or explicit RTL selectors if the visual should mirror.How do I keep CSS grid layouts from causing Cumulative Layout Shift (CLS)?
aspect-ratio on media slots (Demo 19 Aspect-Ratio Tiles) so image containers reserve their height before the img loads — CLS penalty vanishes. (2) Use minmax() with a MIN large enough to fit your smallest realistic content but not so large it wastes space; e.g. minmax(240px, 1fr) for product cards, minmax(320px, 1fr) for dashboard widgets. (3) Avoid grid-auto-rows: auto when row heights depend on async data — pin them with grid-auto-rows: minmax(96px, auto) so the row reserves at least 96px even when data is still loading. Combine with the shimmer skeleton loader pattern (see CSS Shimmer Skeleton Cards) for zero-CLS async grids: the skeleton reserves the exact grid cell dimensions, then the real content swaps in without any reflow. Google's Core Web Vitals docks pages with CLS > 0.1; the aspect-ratio + minmax + shimmer combo keeps CLS at 0.Do these grid layouts work in React / Next.js / Vue / Svelte?
<style> block, CSS Module, or scoped section. Next.js App Router: the layouts sit naturally in a layout.tsx file with <main> hosting the grid children. React Server Components: no hooks needed since these are pure CSS. Vue / Nuxt: drop into any <template> with scoped styles. Svelte / SvelteKit: works in a +page.svelte or +layout.svelte. Astro: paste directly into an .astro file's template. The class prefix .cgl-NN is per-demo scoped so you can drop multiple demos into the same project without collision. Because the layouts are pure CSS (no useEffect, no requestAnimationFrame, no state), you avoid the class of 'grid doesn't render server-side' bugs that plague JS-driven layout libraries — every demo works at first paint, no hydration required.Related collections
15 CSS Aspect Ratio Demos
15 hand-coded CSS aspect-ratio demos for video embeds, product galleries, IAB ad slots, native dialogs, and CLS-safe placeholders: 16:9 iframe YouTube embed with click-to-load facade + up-next rail, 21:9 full-screen hero video with min-height/max-height:100svh guardrails + Ken Burns drift, 1:1 Instagram-style square grid with 2×2 feature tile, 4:3 magazine card image cover, 9:16 vertical stories rail (TikTok/Reels/Shorts pattern) with scroll-snap + segment bars, 4:5 apparel product image gallery with radio-driven state + 1:1 thumbnails, 1:1 zoom thumbnail carousel with pointer-tracked --zx/--zy magnifier, prevent-layout-shift placeholder with live PerformanceObserver CLS meter (before/after side-by-side lab), dynamic content fallback with three policies (bend/strict/auto) via :has() toggle, IAB ad banner slots (728×90 leaderboard, 300×250 medium rectangle, 300×600 half-page, 320×50 mobile) with skeletons + container-query mobile swap, responsive modal dialog sized min(92vw, 88svh×16/9, 1080px) with @starting-style animation, responsive OpenStreetMap iframe wrapper with 16:9 → 1:1 container-query narrow swap, media query orientation live HUD + resize:both container-ratio playground, object-fit logo cloud with contain/cover/fill switcher via :has(), and side-by-side padding-top hack (height:0 + padding-top:56.25%) → modern aspect-ratio migration comparison with live ratio picker. 11 truly Pure CSS + 4 with a tiny optional vanilla JS snippet (facade swap, pointer magnifier, CLS meter, native dialog). Every demo is scoped under a unique .car-NN prefix so it drops into any project without CSS collisions, ships prefers-reduced-motion guards, and is framework-agnostic (works as-is in React, Vue, Svelte, Astro, Next.js, Remix, or plain HTML).
6 CSS Bento Grid Layouts
6 production CSS bento grid layouts with 12 hand-coded designs — Apple-style product showcase, SaaS feature value-prop matrix, analytics dashboard overview, creative portfolio, e-commerce category hub, and link-in-bio social hub. Each topic ships 2 sub-variants side-by-side so visitors see both a keynote aesthetic and a paper-doc variant at once. Container queries, CSS Grid, zero dependencies, copy-paste ready.
20 CSS Blog Layouts
20 hand-coded CSS blog and editorial layouts for magazine homepages, news sites, personal archives, newsletter back-issues, recipe and podcast blogs, developer tutorials, and long-form journalism. Covers a magazine homepage with hero plus editor-picks rail, a news homepage with breaking-news ticker, blog archives with sticky year separators, Substack-style issue-numbered archives, recipe card grids with prep-time badges, podcast episode lists with waveforms, long-form articles with scroll-driven reading progress, drop caps and floated pull quotes via first-letter, Medium-style 65ch centred reader layouts, dev tutorials with a sticky code panel beside prose, interview transcripts with alternating speakers, case-study pages with stat counters, video blogs with an episode rail, full-bleed photo essays, news articles with sticky related-stories sidebars, documentation pages with prev/next chapter nav, a standalone blog post card, a scroll-snap category filter bar, an inline newsletter callout that breaks out of the prose column, and a horizontal featured-post rail. 12 are pure CSS with zero JavaScript. Every layout is scoped under a .bl-NN prefix for no-collision pasting, guards prefers-reduced-motion, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.





























