India · Dubai · Delivering worldwide+91 86603 71224info@pyalm.com
Pyalm Labs logo
Free Tools

CSS Flexbox Cheat Sheet: Every Property with Examples

A practical flexbox reference — container and item properties, the layouts you'll build most, Tailwind equivalents, and when to use grid instead.

Editorial disclosure: Pyalm publishes and maintains the products and free tools discussed on this site. Regulatory statements are linked to primary sources where applicable. No independent professional review is claimed unless a reviewer is explicitly named.

Flexbox lays out items along one axis — a row or a column — and handles spacing and alignment for you. It powers most navigation bars, button groups, card internals and centring tricks on the web.

Container properties

Property Values Tailwind
display flex flex
flex-direction row · row-reverse · column · column-reverse flex-row flex-col
flex-wrap nowrap · wrap · wrap-reverse flex-wrap
justify-content (main axis) flex-start · center · flex-end · space-between · space-around · space-evenly justify-between …
align-items (cross axis) stretch · flex-start · center · flex-end · baseline items-center …
align-content (wrapped lines) flex-start · center · space-between · stretch content-between …
gap length gap-4

Item properties

Property What it does Tailwind
flex-grow Share of spare space the item takes grow
flex-shrink Whether it shrinks when space is tight shrink-0
flex-basis Starting size before growing/shrinking basis-1/3
flex: 1 Grow to fill, starting from 0 flex-1
align-self Override align-items for one item self-end
order Visual order order-first

Layouts you'll build every week

Centre anything: display:flex; justify-content:center; align-items:center;

Nav bar with logo left, links right: display:flex; justify-content:space-between; align-items:center;

Input with button: input gets flex:1, button gets flex-shrink:0.

Responsive card row: display:flex; flex-wrap:wrap; gap:1rem; with each card flex: 1 1 280px;.

Push the last item to the end: give it margin-left:auto.

Try every property live

The free Flexbox Playground lets you flip each container and item property, click items to edit them individually, and copy the result as CSS or Tailwind classes.

Common gotchas

  • justify-content does nothing when items already fill the row or one item has flex-grow.
  • Text overflowing a flex item? Add min-width: 0 — flex items won't shrink below their content by default.
  • Images stretching? align-items: stretch is the default; set align-items: flex-start or give images align-self: center.

Flexbox or grid?

Flexbox for one dimension (a row or a column). Grid when rows and columns must line up together — page layouts, galleries, dashboards.

Rather have it built?

Pyalm designs and builds fast, conversion-focused websites in Next.js — the same stack these tools run on — with a consistent design system, accessible colours and technical SEO built in.

Flexbox Playground | Tailwind Playground | Box Shadow Generator | All free tools

Keep reading

More from Pyalm

Nov 27, 2026

Prescription Abbreviations: What OD, BD, TDS, SOS and 1-0-1 Mean

A plain-English list of prescription abbreviations: dose timing (OD, BD, TDS, QID), when to take (AC, PC, HS, SOS), routes, forms, the 1-0-1 dose grid and abbreviations to avoid.

Nov 27, 2026

Handwritten vs Typed Prescriptions: Which Is Safer?

Why legibility matters in prescribing, what changes when clinics move from handwritten to typed or electronic prescriptions, and how to keep a handwritten signature.

Nov 27, 2026

How to Write a Prescription in India: Format and Rules

A practical prescription format for doctors in India: required details, generic names in capitals, the 1-0-1 grid, Schedule H and controlled drugs, and keeping records.

Nov 27, 2026

Prescription Pad Design: Letterhead Template for Clinics

What a professional prescription letterhead should include, paper size, layout, bilingual Arabic and English pads, QR codes for verification and printing tips.

Nov 27, 2026

Prescription Errors: 10 Common Mistakes and How Clinics Prevent Them

The ten prescription mistakes that cause dispensing errors, from illegible names and decimal points to missing durations, and simple fixes for clinics.

Oct 16, 2026

How to Format and Validate JSON (and Fix the 6 Most Common Errors)

Why JSON breaks, how to read a validator's error message, and a quick routine for pretty-printing, minifying and fixing JSON from APIs, logs and config files.

Try the free Flexbox Playground

Pyalm designs and builds fast, conversion-focused websites in Next.js — the same stack these tools run on. If you'd rather have it built than fiddle with CSS, talk to us.

Open Flexbox Playground See website development All free tools