Loading...
12 essential responsive design patterns — fluid grids, container queries, responsive images, mobile navigation, and Tailwind CSS breakpoint strategies.
/* Fixed max-width with fluid padding */
.container {
width: 100%;
max-width: 1280px;
margin: 0 auto;
padding-inline: clamp(1rem, 5vw, 4rem);
Tailwind equivalent:
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
/* Cards that automatically adjust columns */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
Tailwind:
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
/* Fluid type scale — no media queries needed */
h1 {
font-size: clamp(2rem, 5vw, 4rem);
line-height: 1.1;
}
h2 {
font-size: clamp(1.5rem, 3vw, 2.5rem);
line-height: 1.2;
}
body {
font-size: clamp(1rem, 1vw + 0.75rem, 1.125rem);
line-height: 1.6;
}
<!-- Desktop: horizontal nav | Mobile: hamburger menu -->
<nav class="flex items-center justify-between px-6 py-4">
<a href="/" class="text-xl font-bold">Logo</a>
<!-- Desktop nav -->
<div class="hidden md:flex items-center gap-8">
<a href="/about">About</a>
<a href="/services">Services</a>
<a href="/contact">Contact</a>
</div>
<!-- Mobile hamburger -->
<button class="md:hidden" onclick="toggleMenu()">
<svg class="h-6 w-6"><!-- menu icon --></svg>
</button>
</nav>
<!-- Stacks on mobile, rows on desktop -->
<div class="flex flex-col md:flex-row gap-6">
<div class="md:w-1/3">Sidebar</div>
<div class="md:w-2/3">Main Content</div>
</div>
// Next.js responsive image
import Image from "next/image";
<Image
src="/hero.webp"
alt="Hero section"
width={1200}
height={600}
sizes="(max-width: 640px) 100vw,
(max-width: 1024px) 75vw,
1200px"
className="w-full h-auto rounded-xl"
priority
/>
Our Developer Portfolio Platform auto-converts uploaded images to WebP and generates responsive sizes.
<!-- Scrollable table on mobile -->
<div class="overflow-x-auto">
<table class="min-w-full">
<thead>
<tr>
<th class="whitespace-nowrap px-4 py-3">Name</th>
<th class="whitespace-nowrap px-4 py-3 hidden sm:table-cell">Email</th>
<th class="whitespace-nowrap px-4 py-3 hidden lg:table-cell">Role</th>
<th class="whitespace-nowrap px-4 py-3">Actions</th>
</tr>
</thead>
</table>
</div>
<!-- Spacing that scales with viewport -->
<section class="py-12 sm:py-16 lg:py-24">
<div class="space-y-4 sm:space-y-6 lg:space-y-8">
<!-- Content with responsive gaps -->
</div>
</section>
<form class="space-y-6">
<!-- Full-width on mobile, side-by-side on desktop -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<input type="text" placeholder="First Name" class="w-full px-4 py-3 border rounded-lg" />
<input type="text" placeholder="Last Name" class="w-full px-4 py-3 border rounded-lg" />
</div>
<!-- Always full-width -->
<input type="email" placeholder="Email" class="w-full px-4 py-3 border rounded-lg" />
<!-- Responsive button -->
<button class="w-full sm:w-auto px-8 py-3 bg-indigo-600 text-white rounded-lg">
Submit
</button>
</form>
/* Component responds to its container, not viewport */
.card-wrapper {
container-type: inline-size;
}
@container (min-width: 400px) {
.card { flex-direction: row; }
.card-image { width: 40%; }
}
@container (max-width: 399px) {
.card { flex-direction: column; }
.card-image { width: 100%; aspect-ratio: 16/9; }
}
<!-- Sidebar: full on desktop, overlay on mobile -->
<aside class="fixed inset-y-0 left-0 z-50 w-64 bg-white border-r
transform -translate-x-full lg:translate-x-0 lg:static
transition-transform duration-300"
id="sidebar">
<!-- Sidebar content -->
</aside>
<!-- Overlay backdrop (mobile only) -->
<div class="fixed inset-0 bg-black/50 z-40 lg:hidden hidden" id="backdrop">
</div>
Used in all our dashboard templates: Flavex, NovaAdmin, VelvetAdmin, ZenithUI.
<section class="relative overflow-hidden">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8
py-20 sm:py-28 lg:py-36">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center">
<!-- Text -->
<div class="text-center lg:text-left">
<h1 class="text-4xl sm:text-5xl lg:text-6xl font-bold">
Build Something Amazing
</h1>
<p class="mt-6 text-lg sm:text-xl text-gray-600">
Description text here
</p>
<div class="mt-8 flex flex-col sm:flex-row gap-4
justify-center lg:justify-start">
<a href="#" class="btn-primary">Get Started</a>
<a href="#" class="btn-secondary">Learn More</a>
</div>
</div>
<!-- Image -->
<div class="order-first lg:order-last">
<Image src="/hero.webp" alt="Hero" />
</div>
</div>
</div>
</section>
Breakpoints to test:
320px — Small phones
375px — iPhone SE
390px — iPhone 14
768px — iPad portrait
1024px — iPad landscape / small laptop
1280px — Laptop
1440px — Desktop
1920px — Full HD
2560px — 4K (ensure max-width constraints)
Related reads:
Follow on Instagram for responsive design tips.
Every template, every screen size. Our premium templates implement all 12 patterns — pixel-perfect on every device.
Get the latest articles, tutorials, and updates delivered straight to your inbox. No spam, unsubscribe at any time.