A CSS flexbox layout uses native display: flex to arrange items along one axis with intelligent sizing, spacing, and alignment. These 15 hand-coded layouts are production-ready flexbox templates for the patterns developers ship every day — holy grail page shells, responsive card grids, sticky navbars, sidebar dashboards, pricing tables, sticky footers, kanban boards, chat interfaces and more. Copy the CSS, drop in your content, and ship.

14 pure CSS1 light JSPublished

Related30 CSS Grid Layouts5 CSS Ways to Center a Div15 CSS Card Grid Layouts

CSS Flexbox Holy Grail Layout — preview
01 / 15Pure CSS

CSS Flexbox Holy Grail Layout

A classic holy grail layout — fixed header, footer, left sidebar, right aside, and expanding main column — built entirely with nested flex containers and no CSS Grid.

Published

CSS Flexbox Card Grid Layout — preview
02 / 15Pure CSS

CSS Flexbox Card Grid Layout

A responsive flex card grid with a featured wide card and uniform standard cards that wrap automatically — no media queries required for the basic reflow.

Published

CSS Flexbox Navigation Bar — preview
03 / 15Pure CSS

CSS Flexbox Navigation Bar

Three navigation bar variants — space-between spread, absolutely centered links with flex spacers, and a pill-style active-highlight nav — all built with flex alignment tricks.

Published

CSS Flexbox Masonry-Style Layout — preview
04 / 15Pure CSS

CSS Flexbox Masonry-Style Layout

A multi-column masonry-style card waterfall using flex-direction: column and flex-wrap: wrap with a fixed container height — no JavaScript required.

Published

CSS Flexbox Sidebar Dashboard Layout — preview
05 / 15Pure CSS

CSS Flexbox Sidebar Dashboard Layout

A full app-shell dashboard with a fixed-width flex sidebar, collapsible nav groups, top header bar, stat cards row, and a main content area — all wired with flexbox.

Published

CSS Flexbox Responsive Product Cards — preview
06 / 15Pure CSS

CSS Flexbox Responsive Product Cards

An e-commerce product card grid using flex: 1 1 180px with a max-width cap — cards reflow from four columns to one with no JavaScript or media queries.

Published

CSS Flexbox Pricing Table Layout — preview
07 / 15Pure CSS

CSS Flexbox Pricing Table Layout

A three-tier pricing table with equal-height columns, a scaled featured plan, and flex-driven feature lists — all columns stretch to identical height without JavaScript.

Published

CSS Flexbox Magazine Article Layout — preview
08 / 15Pure CSS

CSS Flexbox Magazine Article Layout

A classic editorial magazine layout with a two-thirds article column, one-third sidebar, drop cap, pull quotes, and a multi-column body text — built with flex and CSS columns.

Published

CSS Flexbox Sticky Footer Layout — preview
09 / 15Pure CSS

CSS Flexbox Sticky Footer Layout

The definitive flexbox sticky footer pattern — a column flex wrapper with min-height: 100% and flex: 1 on the main content pushes the footer to the bottom on any page length.

Published

CSS Flexbox Centered Hero Section — preview
10 / 15Pure CSS

CSS Flexbox Centered Hero Section

A full-bleed hero section with perfect flex centering, animated gradient orbs, a headline group, subtext, and a CTA button row — demonstrating multi-axis flex alignment.

Published

CSS Flexbox Timeline Layout — preview
11 / 15Pure CSS

CSS Flexbox Timeline Layout

A vertical event timeline where each entry is a flex row — a narrow connector column with a dot and line, and an expanding content card — creating a clean left-rail chronology.

Published

CSS Flexbox Chat Interface Layout — preview
12 / 15Pure CSS

CSS Flexbox Chat Interface Layout

A messaging UI with a flex-row shell (contacts sidebar + message pane), scrollable message thread with pinned input bar, and live send interaction — all flex-driven.

Published

CSS Flexbox Mosaic Image Gallery — preview
13 / 15Pure CSS

CSS Flexbox Mosaic Image Gallery

A photo mosaic gallery with three flex columns of varying weights (flex: 2, flex: 1, flex: 1.5) and variable-height tiles, each captioned with a category tag and title — creating an asymmetric editorial grid like Unsplash or Pinterest.

Published

CSS Flexbox Form Layout — preview
14 / 15Pure CSS

CSS Flexbox Form Layout

A structured form layout using flex for single-column fields, inline multi-column field rows, and input groups with prefix/suffix addons — all without tables or floats.

Published

CSS Flexbox Kanban Board Layout — preview
15 / 15CSS + JS

CSS Flexbox Kanban Board Layout

A dark-themed Kanban board with five status columns, draggable task cards, color-coded priority badges, avatar assignments, and a progress bar — built with a horizontal flex shell.

Published

FAQ

Frequently asked questions

What is a CSS flexbox layout?
A CSS flexbox layout uses display: flex on a container so its children arrange themselves along one axis — horizontal (flex-direction: row, the default) or vertical (flex-direction: column). Flex children get intelligent sizing via flex-grow (fill remaining space), flex-shrink (give up space when crowded), and flex-basis (their starting size). Alignment along the main axis uses justify-content; along the cross axis uses align-items. Combined with gap, flex-wrap, and the min-width: 0 trick for overflowing text, flexbox is the right tool for any single-axis arrangement: navbars, button rows, card lists, sidebar shells, chat bubbles, pricing columns, and kanban boards.
When should I use flexbox instead of CSS grid?
Use flexbox when items flow along **one axis** at a time — a navbar where logo + nav + actions sit in a row, a vertical sidebar of menu items, a row of pills, a stack of chat bubbles, a kanban board of vertical columns. Use [CSS grid](/layouts/css-grid-layouts/) when you need to control **both rows and columns at once** — a page shell with header / sidebar / main / footer arranged in named regions, a dashboard with cells that span multiple rows and columns, or a card gallery with explicit row and column tracks. The decision rule: if you're thinking 'arrange these in a line,' reach for flexbox; if you're thinking 'place these into a grid,' reach for grid. Both can be combined — a grid page shell with flex navbars inside it is the most common production pattern, and it's how 7 of the 15 demos in this collection are built.
How do I build a sticky footer with flexbox in 2026?
The modern pattern uses min-block-size: 100dvh on body (the dynamic viewport unit handles iOS Safari's address-bar resize correctly, unlike the legacy 100vh), display: flex, flex-direction: column — then flex: 1 on the main content area. The footer naturally sticks to the bottom because main grows to fill any remaining space. No position: absolute, no negative margins, no calc(100vh - footerHeight) hacks. Demo #09 (CSS Flexbox Sticky Footer Layout) ships the full snippet — copy it as-is and the footer sticks at any content length on any device. The pattern degrades gracefully to 100vh for browsers that don't support 100dvh (Safari < 15.4, Chrome < 108) via min-block-size: 100vh; min-block-size: 100dvh; stacked declarations.
Are these flexbox layouts WCAG-accessible?
Yes. Every layout uses semantic landmark elements — header, nav (with an aria-label), main, aside, and footer — so screen readers expose document structure correctly. Interactive controls are real button and anchor elements with visible focus-visible rings — the kanban demo (Demo #15) keeps focus inside its column when items reorder, and the chat demo (Demo #12) uses aria-live polite on the message list so new bubbles are announced. The navbar (Demo #03) and sidebar (Demo #05) both expose aria-current page on the active link. All demos meet WCAG 2.2 AA contrast (≥ 4.5:1 for body, ≥ 3:1 for UI components) and target Section 508 / EU EAA compliance — audit any of them with axe DevTools or Lighthouse's accessibility audit to verify the color and ARIA pass.
Why does my flexbox text overflow its container?
Flex items have an implicit min-width: auto that resolves to their intrinsic content size — so a long URL, an unbreakable word, or an inline code block inside a flex child can push the whole container wider than its parent and break the layout. The fix is one line: min-width: 0 on the offending flex child. This unlocks the normal CSS overflow behavior (overflow: hidden, text-overflow: ellipsis, white-space: nowrap then work as expected). Pair it with flex: 1 1 auto for shrinkable text content and flex-shrink: 0 for fixed-width siblings (icons, indicators). This is the single most common flexbox bug — every demo in this collection that has shrinkable text content (chat #12, navbar #03, magazine #08) applies the min-width: 0 defensively so it never bites users who copy and adapt the code.
How do these flexbox layouts compare to Tailwind, Bootstrap, MUI, Chakra, and shadcn/ui?
**Tailwind CSS** ships utility classes that one-to-one map to flexbox properties: flex = display: flex, flex-row / flex-col, justify-between / items-center / gap-4, flex-1 / flex-shrink-0 / min-w-0. Each demo here translates directly — copy the structural decisions (which child gets flex: 1, which gets min-width: 0) into Tailwind utilities. **Bootstrap 5** uses similar tokens via its d-flex / justify-content-between / align-items-center / flex-fill / flex-shrink-0 utilities — the grid module above is built on flexbox under the hood. **MUI** (Material UI) exposes flexbox via its Stack and Box components and their props (direction, spacing, justifyContent). **Chakra UI** has Flex, HStack, and VStack primitives. **shadcn/ui** components use Tailwind utilities directly so any pattern here works inside a shadcn project unchanged. The underlying CSS knowledge is portable across all five frameworks — these demos teach the pattern; the framework adds syntactic sugar. Want the converted utilities? Drop a demo's CSS into our [CSS to Tailwind converter](/tools/css-to-tailwind-converter/) to see the utility-class equivalent.
What's the right flexbox alternative to CSS masonry?
True CSS masonry (grid-template-rows: masonry) is still behind a flag in most browsers as of 2026 — it ships in Firefox but isn't in Chrome / Safari stable yet. The cleanest flexbox alternative uses flex-direction: column with multiple columns and a column-count fallback, or — more commonly — three or four vertical flex columns each containing items of varying height, items distributed in render order. Demo #04 (CSS Flexbox Masonry-Style Layout) ships this pattern: three columns side-by-side (display: flex), each column is itself a flex container (flex-direction: column; gap), and items are distributed across columns in render order. The visual result reads as a Pinterest-style masonry. The tradeoff: items aren't auto-balanced across columns (you may end up with one taller column), but it works in every browser today with no JavaScript. When grid-template-rows: masonry ships universally, swap the flex columns for a CSS grid container — the markup stays the same.
Are these CSS flexbox layouts free and how should I attribute them?
Yes — all 15 layouts are MIT licensed and free for personal and commercial use, including in client projects, SaaS products, and design systems. The MIT license requires only that you keep the copyright notice somewhere in your source if you redistribute the code as-is; in production HTML / CSS that you've adapted, no visible attribution is needed. If you ship one of these as part of an open-source UI library, include a one-line credit in your README pointing to https://codefronts.com — that helps the project and is appreciated but not legally required. The code panels show exactly what to copy: the HTML tab is your markup, the CSS tab is your stylesheet, and the JS tab (where present — Demo #15 kanban only) is the optional vanilla JavaScript handler. Every snippet is self-contained, framework-free, and works at any viewport from 320px (mobile) to 1440px+ (desktop wide) without modification.

Related collections

15 CSS Aspect Ratio Demos preview

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 preview

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 preview

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.

Search CodeFronts

Loading…