home / skills / secondsky / claude-skills / responsive-web-design

This skill helps you design responsive web interfaces with mobile-first CSS, flexible grids, and fluid typography across devices.

npx playbooks add skill secondsky/claude-skills --skill responsive-web-design

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.0 KB
---
name: responsive-web-design
description: Builds adaptive web interfaces using Flexbox, CSS Grid, and media queries with a mobile-first approach. Use when creating multi-device layouts, implementing flexible UI systems, or ensuring cross-browser compatibility.
---

# Responsive Web Design

Build adaptive interfaces using modern CSS techniques for all screen sizes.

## Mobile-First Media Queries

```css
/* Base: Mobile (320px+) */
.container {
  padding: 1rem;
}

/* Tablet (640px+) */
@media (min-width: 640px) {
  .container {
    padding: 2rem;
    max-width: 640px;
    margin: 0 auto;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}
```

## Flexible Grid

```css
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr; /* Mobile: single column */
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, 1fr); /* Tablet: 2 columns */
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr); /* Desktop: 3 columns */
  }
}
```

## Fluid Typography

```css
/* Scales smoothly between breakpoints */
h1 {
  font-size: clamp(1.5rem, 4vw, 3rem);
}

p {
  font-size: clamp(1rem, 2vw, 1.25rem);
}
```

## Responsive Images

```css
img {
  max-width: 100%;
  height: auto;
}

.hero-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
```

## Flexbox Navigation

```css
.nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .nav {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
```

## Best Practices

- Start with mobile styles first
- Use flexible units (%, rem, vw)
- Test on real devices
- Ensure minimum 48px touch targets
- Maintain readable line lengths (45-75 chars)
- Use CSS Grid for 2D layouts, Flexbox for 1D

## Resources

- [MDN Flexbox Guide](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout)
- [MDN Grid Guide](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout)

Overview

This skill builds adaptive web interfaces using Flexbox, CSS Grid, and mobile-first media queries to ensure layouts work smoothly across devices. It focuses on practical, production-ready patterns for fluid typography, responsive images, and flexible navigation. The goal is consistent cross-browser behavior and accessible touch-friendly interactions.

How this skill works

The skill provides CSS patterns and breakpoints that start from a mobile baseline and progressively enhance for larger viewports. It uses Grid for two-dimensional layouts, Flexbox for one-dimensional flows like navs, and clamp() and viewport-relative units for fluid typography. Responsive images and aspect-ratio rules keep media scalable and performant across screen sizes.

When to use it

  • Building new multi-device layouts with predictable breakpoints
  • Converting fixed-width designs into adaptive, responsive interfaces
  • Implementing flexible UI systems that must scale across components
  • Ensuring accessible touch targets and readable typography on mobile-first projects
  • Optimizing images and media for different aspect ratios and viewports

Best practices

  • Start with mobile-first CSS and add media queries with min-width
  • Prefer flexible units: rem, %, vw and clamp() for fluid scaling
  • Use CSS Grid for complex 2D layouts and Flexbox for rows/columns and navs
  • Keep touch targets at least 48px and maintain 45–75 character line lengths
  • Test layouts on real devices and in multiple browsers for cross-compatibility
  • Use max-width:100% and aspect-ratio for responsive images and media

Example use cases

  • Create a product grid that shifts from 1 column (mobile) to 2 columns (tablet) to 3 columns (desktop) using grid-template-columns
  • Build a header/nav that stacks vertically on phone and lays out horizontally on larger screens with flex-direction changes
  • Implement fluid headings and body text using clamp() to scale type between breakpoints
  • Design a responsive hero image that preserves a 16:9 aspect ratio and covers the container
  • Migrate a legacy site to a mobile-first responsive system using the provided breakpoints and units

FAQ

What breakpoints should I use?

Use mobile-first breakpoints that match your audience; common ones are min-width:640px for tablet and min-width:1024px for desktop, but adjust based on your design and analytics.

When should I choose Grid vs Flexbox?

Use Grid for two-dimensional layouts (rows and columns together) like card grids. Use Flexbox for one-dimensional arrangements such as nav bars, toolbars, or aligning items along a single axis.