Responsive CSS Layout Recipes

Small CSS patterns for resilient columns, readable text, scrollable data, and mobile controls.

  • JSON5,437 B
  • YAML3,901 B · −28%
  • TOON3,312 B · −39%

Small CSS patterns for resilient columns, readable text, scrollable data, and mobile controls. Each row includes a practical application and a failure to check before using it.

Use it when

  • Fix page overflow without hiding the offending content.
  • Build a responsive reference or documentation page.

Watch out for

  • Snippets need to be adapted to their containing layout.
  • Do not use overflow hidden to conceal inaccessible data.

The data

TaskCssReasonCheck
Bounded contentwidth: min(100% - 32px, 1200px); margin-inline: autoUse a shared gutter with a maximum reading canvas.Test at 320 CSS pixels and with large text.
Flexible two-column griddisplay: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr)Allow content tracks to shrink below intrinsic widths.Collapse when the content becomes cramped.
Shrinkable flex childmin-width: 0Allow a long label to fit inside a flex row.Without it, intrinsic width may force page overflow.
Readable prosemax-width: 70ch; line-height: 1.7Constrain line length while keeping vertical rhythm.Actual character widths vary with the font.
Wide reference tableoverflow-x: auto; max-width: 100%Keep horizontal scrolling inside the table region.Make the region keyboard reachable and label it.
Touch targetmin-height: 44px; min-width: 44pxProvide a practical touch area for controls.WCAG target-size criteria have additional details and exceptions.
Long URLoverflow-wrap: anywherePermit unbroken source URLs to wrap.Keep code blocks scrollable instead of breaking syntax.
Sticky sidebarposition: sticky; top: 96px; align-self: startKeep reference navigation near the data.Disable or bound it when the viewport is short.
Reduced motion@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }Avoid unnecessary animated scrolling.Controls must still communicate state.
Responsive mediawidth: 100%; height: auto; aspect-ratio: 16 / 9Reserve space for a visual while preserving proportions.Do not assign a conflicting fixed height.

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
datataskstringBounded content
datacssstringwidth: min(100% - 32px, 1200px); margin-inline:…
datareasonstringUse a shared gutter with a maximum reading canv…
datacheckstringTest at 320 CSS pixels and with large text.

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/css-layout-recipes?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/css-layout-recipes.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Sources and editorial notes

Original editorial reference notes by YJTOON, informed by the linked primary documentation. External specifications retain their own licenses.

Editorial review: . Source documents keep their own licenses.

Topics

  • web-technologies
  • css layout recipes
  • reference
  • engineering

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets