Responsive Breakpoint & Layout Calculator
Configure a synchronized breakpoint scale for media queries and modern CSS container queries, then calculate exact aspect-ratio dimensions that eliminate Cumulative Layout Shift.
Breakpoint Scale
Simulate Viewport
1024pxAt 1024px, the active breakpoint is lg.
:root {
--breakpoint-sm: 640px;
--breakpoint-md: 768px;
--breakpoint-lg: 1024px;
--breakpoint-xl: 1280px;
--breakpoint-2xl: 1536px;
}
@media (min-width: 640px) { /* sm and up */ }
@media (min-width: 768px) { /* md and up */ }
@media (min-width: 1024px) { /* lg and up */ }
@media (min-width: 1280px) { /* xl and up */ }
@media (min-width: 1536px) { /* 2xl and up */ }Aspect-Ratio & CLS Calculator
Live Preview
.media {
aspect-ratio: 16 / 9;
width: 100%;
height: auto;
}Media Queries, Container Queries & CLS
Why Combine Media Queries with Container Queries?
A media query only knows about the browser's viewport — a card inside a narrow sidebar still gets the "desktop" styles if the window is wide. A container query responds to the width of its own parent instead, so the same card component adapts correctly whether it's in a full-width feed or a 320px sidebar. Both use the same kind of min-width thresholds, which is why this tool generates them from one shared breakpoint scale.
How Aspect-Ratio Prevents Layout Shift
Cumulative Layout Shift (CLS) happens when content jumps because the browser didn't know how much space to reserve before an image finished loading. Setting an explicit aspect-ratio (or width/height attributes) lets the browser calculate and reserve the exact box up front — the layout never moves once the image bytes arrive.
Step-by-Step: How to Use This Calculator
Pick a breakpoint preset, or dial in your own
Tailwind Defaults matches the ecosystem most component libraries expect. Device-Based mirrors real phone/tablet/laptop/desktop/ultrawide widths if you're designing from device mockups.
Simulate a viewport to sanity-check the scale
Drag the Simulate Viewport slider and watch which named breakpoint lights up — a fast way to confirm your thresholds land where you expect before you ship them.
Export both media and container query CSS
Use @media for page-level layout (nav, page grid) and @container for reusable components (cards, widgets) that need to adapt to whatever container they're dropped into.
Compute exact image dimensions per breakpoint
Pick your image's aspect ratio and the width it actually renders at (not the source file's dimensions), and copy the exact height into your CSS or Next.js Image component.
Frequently Asked Questions
What's the difference between @media and @container?
@media reads the browser viewport - the same styles apply everywhere on the page. @container reads the width of a specific parent element, so the same component can respond differently depending on where it's placed.
Do I need container-type: inline-size for @container to work?
Yes - a container query only works on an ancestor that has explicitly opted in with container-type (and optionally container-name), which is why this tool generates that declaration alongside the queries themselves.
Why does the aspect-ratio calculator ask for 'target render width', not the image's real size?
CLS prevention only cares about how large the image will actually display on the page - the source file can be a completely different resolution. Using the rendered width keeps the reserved space accurate.
Do I still need the padding-top percentage hack?
Almost never for modern projects - the CSS aspect-ratio property has excellent support in all current browsers. The legacy fallback is included for projects that still need to support very old browser versions.
Suggested Tools for Your Stack
Explore related utilities in this workflow or discover cross-category tools.
Related in Design Systems & Code
SaaS Design Token & Theme Studio
Generate 8pt spacing scales, typography ramps, and export to Tailwind v3/v4 & Figma JSON.
Accessible SaaS Color Palette Generator
Generate harmonious 10-shade UI color ramps (50–950) with automated WCAG contrast validation.
Recommended from Other Categories
SaaS UX & Friction Audit
0–100 Product Experience Score across onboarding, IA, visual hierarchy, and navigation.
SaaS Pricing Page & Psychology Analyzer
Audit tier differentiation, annual toggle psychology, feature comparison, and objection handling.