Building Responsive Layouts
In 2026, Responsive Layouts have evolved from simply "stacking columns" to creating interfaces that fluidly adapt to screen size, device type (foldables/ultrawides), and even user preference (light/dark/motion).
Responsive design is essential today.
Modern responsiveness relies on three pillars that minimize the need for complex media queries:
- CSS Grid & Flexbox: Use
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))to create cards that wrap automatically without a single media query. - Container Queries (
@container): Perhaps the biggest shift. Instead of styling based on the viewport (screen size), parent container. This makes components truly plug-and-play. - Modern Units: Move beyond
px. Useclamp(1rem, 5vw, 2rem)for fluid typography that scales perfectly between mobile and desktop.
Best Practices for 2026
- Mobile-First: Always write your base styles for the smallest screen and use
@media (min-width: ...)to add complexity as the screen grows. This reduces CSS payload and improves performance. - Logical Properties: Use
margin-inlineandpadding-blockinstead ofleft/right/top/bottom. This ensures your layout stays responsive even when translated to Right-to-Left (RTL) languages. - Foldable Support: With the rise of dual-screen devices, use the
screen-spanningmedia feature to handle the "hinge" or "fold" in the middle of the display.
Grid Layout
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}⚠️ Note: Always test on real devices.