Responsive CSS Patterns
Breakpoints are the tool; patterns are the craft. Fluid containers, flexible media, responsive type, and layouts that reflow on their own — the recipes professionals reuse on every build.
1. The foundational three
/* 1. the viewport meta (HTML, not CSS — but mandatory) */
<meta name="viewport" content="width=device-width, initial-scale=1">
/* 2. fluid container */
.container { width: 90%; max-width: 1100px; margin: 0 auto; }
/* 3. flexible media */
img, video { max-width: 100%; height: auto; }Without the viewport meta tag, phones render a zoomed-out desktop page and every query lies. The fluid container and the media rule prevent the two classic mobile bugs: fixed-width layouts and images blasting out of their columns.
2. Layouts that adapt themselves
/* wrapping cards (flexbox) */
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > * { flex: 1 1 240px; }
/* auto-fitting grid */
.grid { display: grid; gap: 16px;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
/* fluid type */
h1 { font-size: clamp(1.8rem, 4vw, 3.2rem); }Each recipe adapts continuously — no breakpoints to maintain. Combine them with a handful of media queries for the big structural shifts (sidebar collapsing, nav becoming a drawer) and you have the architecture of this very site.
3. Try it yourself
Apply two patterns: make the image flexible (max-width:100%; height:auto) and turn the row into wrapping cards with flex: 1 1 150px on the children.
4. Quiz — check your understanding
Responsive CSS Patterns Quiz
4 questions · pass at 60%Q1. Why is the viewport meta tag essential?
Q2. The standard flexible-media rule is…
Q3. flex: 1 1 240px on cards in a wrapping row means…
Q4. Which adapts WITHOUT any media query?
Every lesson quiz you pass (60%+) is saved in your browser and counts toward the CSSmatic Certificate of Completion.