CSS Free, no sign-up

CSS Container Queries (@container) Generator

Classic @media queries only know the full browser viewport. Placing a card in a narrow sidebar on an ultrawide monitor breaks layout because @media assumes massive screen real estate. With container-type: inline-size and @container, components respond directly to their allocated space anywhere in the UI.

Result
Ready-made CSS
/* 1. Valideyn konteyneri elan edirik */
.card-wrapper {
  container-type: inline-size;
  container-name: card;
}

/* 2. Kart öz konteynerinin eninə uyğunlaşır */
.card {
  display: flex;
  flex-direction: column;
}

@container card (min-width: 400px) {
  .card {
    flex-direction: row;
    align-items: center;
  }
}

How to use it

  1. Drag the right handle of the interactive preview (or use the width slider) to watch the card adapt its internal layout in real time.
  2. Switch between presets: 'Narrow Sidebar (260px)', 'Feed Column (420px)', or 'Wide Section (580px)'.
  3. Watch breakpoints toggle automatically when container width crosses 380px and 500px thresholds.
  4. Copy the production-ready modular @container CSS code.

How it works

Why Container Queries revolutionizes responsive web design

For decades responsive design was tied strictly to viewport width (@media). But modern web apps are built with modular design systems. The exact same card widget might live in a tight 300px sidebar or an 800px main column. @container decouples components from page viewport dimensions entirely.

How container-type: inline-size works

container-type: inline-size declares an element as a query container along its inline (horizontal) axis. Child elements query the parent's actual render width using @container (min-width: ...).

.widget-parent {
  container-type: inline-size;
  container-name: widget;
}

@container widget (min-width: 400px) {
  .widget { display: flex; flex-direction: row; }
}

Container Query Units: cqw and cqi

Container queries introduce container relative units: 1cqw is 1% of the container's width, while 1cqi is 1% of the container's inline size. Typography and padding can scale fluidly with component footprint rather than viewport width.

FAQ

What is browser support for Container Queries?

Fully supported across all major browsers (Chrome 105+, Safari 16+, Firefox 110+, Edge 105+) since early 2023 with over 92% global coverage.

Why is inline-size preferred over size?

size monitors both width and height, creating cyclic dependency risks where children increase height and alter parent size. inline-size monitors width only, allowing vertical content to expand safely.

Is container-name mandatory?

No. When omitted, @container (min-width: ...) automatically queries the nearest ancestor with an active container-type.

This topic in the HTML & CSS course

More CSS tools

CSS gradient generator Linear, radial and conic gradients: pick colors, angle and stops, then copy the code. Flexbox generator and playground Try flex properties on a container and its items: direction, alignment, gaps and ready-made CSS. CSS Grid generator Set columns and rows, gaps and alignment, then copy the ready-made grid code. CSS box-shadow generator Pick offset, blur, color and layers for a shadow, then copy the ready-made box-shadow code. Cubic-bezier generator Drag the control points of an easing curve and copy the ready-made CSS transition. SVG animation generator Pick a shape and an effect — get inline SVG and CSS keyframes ready to paste. CSS specificity calculator Type selectors to see their (a,b,c) weight, a color-coded breakdown and which rule wins. CSS box model visualizer See content, padding, border and margin as a DevTools-style diagram and copy the CSS. CSS transform generator Move, rotate, scale and skew an element, see its original position and copy the code. CSS clamp() calculator Enter min and max font size and viewport width — get a ready clamp() for fluid typography. Color contrast checker (WCAG) Check text and background contrast against WCAG AA and AAA, and fix a failing pair of colors. CSS clip-path generator Polygons, bevels, arrows and circles: drag control points on the live canvas and copy ready-made CSS. CSS glassmorphism generator Frosted glass effect: backdrop-filter blur, saturation, border highlight and clean CSS. CSS border-radius (Blob) generator Organic shapes and 8-value border-radius: tune horizontal and vertical corner radii. CSS Stacking Context & z-index Visualizer Why z-index: 9999 fails! Explore CSS Stacking Contexts in interactive 3D exploded layers with transform, opacity and isolation triggers. CSS aspect-ratio & object-fit Generator Eliminate squished images & CLS layout jumps: live aspect-ratio proportions and interactive object-position focal point. CSS Filters Studio & Generator Photo effects without design tools: blur, contrast, hue-rotate, sepia, and trending Instagram-style presets. OKLCH Color Picker & Palette Generator Perceptually uniform brightness & vibrant Display P3 colors: OKLCH picker, design system scales, and fallbacks. CSS Scroll-driven Animations Generator Scroll-linked animations without JavaScript: animation-timeline scroll() & view(), reading progress bar & reveal on scroll.
WhatsApp