@champpaba/claude-agent-kit 3.0.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/CHANGELOG.md +707 -0
- package/.claude/CLAUDE.md +128 -613
- package/.claude/agents/_shared/pre-work-checklist.md +108 -7
- package/.claude/commands/cdev.md +36 -0
- package/.claude/commands/csetup.md +292 -1791
- package/.claude/commands/cview.md +364 -364
- package/.claude/contexts/design/accessibility.md +611 -611
- package/.claude/contexts/design/layout.md +400 -400
- package/.claude/contexts/design/responsive.md +551 -551
- package/.claude/contexts/design/shadows.md +522 -522
- package/.claude/contexts/design/typography.md +465 -465
- package/.claude/contexts/domain/README.md +164 -164
- package/.claude/contexts/patterns/agent-coordination.md +388 -388
- package/.claude/contexts/patterns/development-principles.md +513 -513
- package/.claude/contexts/patterns/error-handling.md +478 -478
- package/.claude/contexts/patterns/logging.md +424 -424
- package/.claude/contexts/patterns/tdd-classification.md +516 -516
- package/.claude/contexts/patterns/testing.md +413 -413
- package/.claude/lib/README.md +3 -3
- package/.claude/lib/detailed-guides/taskmaster-analysis.md +1 -1
- package/.claude/lib/task-analyzer.md +144 -0
- package/.claude/lib/tdd-workflow.md +2 -1
- package/.claude/lib/validation-gates.md +484 -484
- package/.claude/settings.local.json +42 -42
- package/.claude/templates/PROJECT_STATUS.template.yml +16 -41
- package/.claude/templates/context-template.md +45 -45
- package/.claude/templates/flags-template.json +42 -42
- package/.claude/templates/phases-sections/accessibility-test.md +17 -17
- package/.claude/templates/phases-sections/api-design.md +37 -37
- package/.claude/templates/phases-sections/backend-tests.md +16 -16
- package/.claude/templates/phases-sections/backend.md +37 -37
- package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
- package/.claude/templates/phases-sections/component-tests.md +17 -17
- package/.claude/templates/phases-sections/contract-backend.md +16 -16
- package/.claude/templates/phases-sections/contract-frontend.md +16 -16
- package/.claude/templates/phases-sections/database.md +35 -35
- package/.claude/templates/phases-sections/e2e-tests.md +16 -16
- package/.claude/templates/phases-sections/fix-implementation.md +17 -17
- package/.claude/templates/phases-sections/frontend-integration.md +18 -18
- package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
- package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
- package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
- package/.claude/templates/phases-sections/refactor.md +16 -16
- package/.claude/templates/phases-sections/regression-tests.md +15 -15
- package/.claude/templates/phases-sections/responsive-test.md +16 -16
- package/.claude/templates/phases-sections/script-implementation.md +43 -43
- package/.claude/templates/phases-sections/test-coverage.md +16 -16
- package/.claude/templates/phases-sections/user-approval.md +14 -14
- package/LICENSE +21 -21
- package/package.json +1 -1
- package/.claude/lib/tdd-classifier.md +0 -345
|
@@ -1,551 +1,551 @@
|
|
|
1
|
-
# Responsive Design
|
|
2
|
-
|
|
3
|
-
> **Purpose:** Adaptive layouts that work across all screen sizes
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Mobile-First Philosophy
|
|
8
|
-
|
|
9
|
-
**Core Principle:** Design for mobile, enhance for desktop
|
|
10
|
-
|
|
11
|
-
**Why Mobile-First?**
|
|
12
|
-
- ✅ Forces prioritization of essential content
|
|
13
|
-
- ✅ Better performance (load only what's needed)
|
|
14
|
-
- ✅ Easier to scale up than down
|
|
15
|
-
- ✅ Matches user behavior (60%+ mobile traffic)
|
|
16
|
-
|
|
17
|
-
**Implementation:**
|
|
18
|
-
```css
|
|
19
|
-
/* ✅ Mobile-first (recommended) */
|
|
20
|
-
.element {
|
|
21
|
-
/* Mobile styles (default) */
|
|
22
|
-
width: 100%;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media (min-width: 640px) {
|
|
26
|
-
.element {
|
|
27
|
-
/* Tablet styles */
|
|
28
|
-
width: 50%;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@media (min-width: 1024px) {
|
|
33
|
-
.element {
|
|
34
|
-
/* Desktop styles */
|
|
35
|
-
width: 33.333%;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* ❌ Desktop-first (avoid) */
|
|
40
|
-
.element {
|
|
41
|
-
width: 33.333%; /* Desktop default */
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@media (max-width: 1023px) {
|
|
45
|
-
.element {
|
|
46
|
-
width: 50%; /* Tablet override */
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@media (max-width: 639px) {
|
|
51
|
-
.element {
|
|
52
|
-
width: 100%; /* Mobile override */
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Breakpoint System
|
|
60
|
-
|
|
61
|
-
### 3-Tier Standard Breakpoints
|
|
62
|
-
|
|
63
|
-
| Tier | Min Width | Target Devices | Common Resolutions |
|
|
64
|
-
|------|-----------|----------------|-------------------|
|
|
65
|
-
| **Mobile** | < 640px | Phones | 375px, 414px |
|
|
66
|
-
| **Tablet** | 640px - 1024px | Tablets, small laptops | 768px, 834px, 1024px |
|
|
67
|
-
| **Desktop** | > 1024px | Laptops, desktops | 1280px, 1440px, 1920px |
|
|
68
|
-
|
|
69
|
-
**Implementation:**
|
|
70
|
-
```css
|
|
71
|
-
:root {
|
|
72
|
-
--breakpoint-sm: 640px; /* Tablets */
|
|
73
|
-
--breakpoint-md: 768px; /* Small laptops */
|
|
74
|
-
--breakpoint-lg: 1024px; /* Desktops */
|
|
75
|
-
--breakpoint-xl: 1280px; /* Large desktops */
|
|
76
|
-
--breakpoint-2xl: 1536px; /* Extra large */
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Usage */
|
|
80
|
-
@media (min-width: 640px) { /* Tablet+ */ }
|
|
81
|
-
@media (min-width: 1024px) { /* Desktop+ */ }
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### Extended Breakpoints (Optional)
|
|
87
|
-
|
|
88
|
-
**For projects needing more granularity:**
|
|
89
|
-
|
|
90
|
-
| Size | Min Width | Use Case |
|
|
91
|
-
|------|-----------|----------|
|
|
92
|
-
| xs | < 480px | Small phones |
|
|
93
|
-
| sm | 640px | Tablets |
|
|
94
|
-
| md | 768px | Small laptops |
|
|
95
|
-
| lg | 1024px | Desktops |
|
|
96
|
-
| xl | 1280px | Large desktops |
|
|
97
|
-
| 2xl | 1536px | Extra large screens |
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## Responsive Box Movement
|
|
102
|
-
|
|
103
|
-
**Core Concept:** Describe layouts in terms of box behavior, not pixels
|
|
104
|
-
|
|
105
|
-
### Stacking Pattern
|
|
106
|
-
|
|
107
|
-
**Desktop (Horizontal) → Mobile (Vertical)**
|
|
108
|
-
|
|
109
|
-
```css
|
|
110
|
-
/* Desktop: Side-by-side */
|
|
111
|
-
.container {
|
|
112
|
-
display: flex;
|
|
113
|
-
gap: var(--spacing-6);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/* Mobile: Stacked */
|
|
117
|
-
@media (max-width: 639px) {
|
|
118
|
-
.container {
|
|
119
|
-
flex-direction: column;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Visual:**
|
|
125
|
-
```
|
|
126
|
-
Desktop (> 1024px):
|
|
127
|
-
┌────────────┬────────────┐
|
|
128
|
-
│ Sidebar │ Main │
|
|
129
|
-
└────────────┴────────────┘
|
|
130
|
-
|
|
131
|
-
Mobile (< 640px):
|
|
132
|
-
┌────────────┐
|
|
133
|
-
│ Main │
|
|
134
|
-
├────────────┤
|
|
135
|
-
│ Sidebar │
|
|
136
|
-
└────────────┘
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
### Merging Pattern
|
|
142
|
-
|
|
143
|
-
**Multiple Boxes → Single Unified Box**
|
|
144
|
-
|
|
145
|
-
```css
|
|
146
|
-
/* Desktop: 3 columns */
|
|
147
|
-
.grid {
|
|
148
|
-
display: grid;
|
|
149
|
-
grid-template-columns: repeat(3, 1fr);
|
|
150
|
-
gap: var(--spacing-6);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/* Tablet: 2 columns */
|
|
154
|
-
@media (max-width: 1023px) {
|
|
155
|
-
.grid {
|
|
156
|
-
grid-template-columns: repeat(2, 1fr);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/* Mobile: 1 column */
|
|
161
|
-
@media (max-width: 639px) {
|
|
162
|
-
.grid {
|
|
163
|
-
grid-template-columns: 1fr;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
### Prioritizing Pattern
|
|
171
|
-
|
|
172
|
-
**Important Content First, Secondary Content Hidden/Moved**
|
|
173
|
-
|
|
174
|
-
```css
|
|
175
|
-
/* Desktop: Show all */
|
|
176
|
-
.header {
|
|
177
|
-
display: flex;
|
|
178
|
-
justify-content: space-between;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.nav {
|
|
182
|
-
display: flex;
|
|
183
|
-
gap: var(--spacing-6);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/* Mobile: Hide nav, show hamburger */
|
|
187
|
-
@media (max-width: 767px) {
|
|
188
|
-
.nav {
|
|
189
|
-
display: none; /* Hidden by default */
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.nav.open {
|
|
193
|
-
display: flex;
|
|
194
|
-
flex-direction: column;
|
|
195
|
-
position: fixed;
|
|
196
|
-
top: 0;
|
|
197
|
-
left: 0;
|
|
198
|
-
width: 100%;
|
|
199
|
-
height: 100vh;
|
|
200
|
-
background: white;
|
|
201
|
-
padding: var(--spacing-6);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.hamburger {
|
|
205
|
-
display: block; /* Visible on mobile */
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
### Compressing Pattern
|
|
213
|
-
|
|
214
|
-
**Boxes Shrink, Maintain Relationships**
|
|
215
|
-
|
|
216
|
-
```css
|
|
217
|
-
/* Desktop: Generous spacing */
|
|
218
|
-
.section {
|
|
219
|
-
padding: var(--spacing-12); /* 48px */
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/* Tablet: Medium spacing */
|
|
223
|
-
@media (max-width: 1023px) {
|
|
224
|
-
.section {
|
|
225
|
-
padding: var(--spacing-8); /* 32px */
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/* Mobile: Compact spacing */
|
|
230
|
-
@media (max-width: 639px) {
|
|
231
|
-
.section {
|
|
232
|
-
padding: var(--spacing-4); /* 16px */
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
**Scaling Pattern:** 2x (desktop) → 1.5x (tablet) → 1x (mobile)
|
|
238
|
-
|
|
239
|
-
---
|
|
240
|
-
|
|
241
|
-
## Responsive Typography
|
|
242
|
-
|
|
243
|
-
### Fluid Font Sizes
|
|
244
|
-
|
|
245
|
-
**Method 1: Breakpoint-Based (Simple)**
|
|
246
|
-
|
|
247
|
-
```css
|
|
248
|
-
/* Mobile */
|
|
249
|
-
h1 {
|
|
250
|
-
font-size: 2rem; /* 32px */
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/* Tablet */
|
|
254
|
-
@media (min-width: 640px) {
|
|
255
|
-
h1 {
|
|
256
|
-
font-size: 2.25rem; /* 36px */
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/* Desktop */
|
|
261
|
-
@media (min-width: 1024px) {
|
|
262
|
-
h1 {
|
|
263
|
-
font-size: 2.5rem; /* 40px */
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
**Method 2: clamp() Function (Fluid)**
|
|
269
|
-
|
|
270
|
-
```css
|
|
271
|
-
h1 {
|
|
272
|
-
/* min, preferred (scales with viewport), max */
|
|
273
|
-
font-size: clamp(2rem, 4vw, 2.5rem);
|
|
274
|
-
/* 32px minimum, scales between, 40px maximum */
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
h2 {
|
|
278
|
-
font-size: clamp(1.5rem, 3vw, 2rem);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
p {
|
|
282
|
-
font-size: clamp(1rem, 1.5vw, 1.125rem);
|
|
283
|
-
}
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
**Benefits of clamp():**
|
|
287
|
-
- ✅ Smoothly scales between breakpoints
|
|
288
|
-
- ✅ No media queries needed
|
|
289
|
-
- ✅ Better user experience (no jumps)
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
## Responsive Images
|
|
294
|
-
|
|
295
|
-
### Techniques
|
|
296
|
-
|
|
297
|
-
**1. Fluid Images (Default)**
|
|
298
|
-
```css
|
|
299
|
-
img {
|
|
300
|
-
max-width: 100%;
|
|
301
|
-
height: auto;
|
|
302
|
-
display: block;
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
**2. Picture Element (Art Direction)**
|
|
307
|
-
```html
|
|
308
|
-
<picture>
|
|
309
|
-
<!-- Desktop -->
|
|
310
|
-
<source media="(min-width: 1024px)" srcset="hero-desktop.jpg">
|
|
311
|
-
|
|
312
|
-
<!-- Tablet -->
|
|
313
|
-
<source media="(min-width: 640px)" srcset="hero-tablet.jpg">
|
|
314
|
-
|
|
315
|
-
<!-- Mobile (default) -->
|
|
316
|
-
<img src="hero-mobile.jpg" alt="Hero">
|
|
317
|
-
</picture>
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
**3. srcset (Resolution Switching)**
|
|
321
|
-
```html
|
|
322
|
-
<img
|
|
323
|
-
srcset="image-small.jpg 480w,
|
|
324
|
-
image-medium.jpg 768w,
|
|
325
|
-
image-large.jpg 1200w"
|
|
326
|
-
sizes="(max-width: 640px) 100vw,
|
|
327
|
-
(max-width: 1024px) 50vw,
|
|
328
|
-
33vw"
|
|
329
|
-
src="image-medium.jpg"
|
|
330
|
-
alt="Responsive image"
|
|
331
|
-
>
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
**4. Background Images**
|
|
335
|
-
```css
|
|
336
|
-
.hero {
|
|
337
|
-
background-image: url('hero-mobile.jpg');
|
|
338
|
-
background-size: cover;
|
|
339
|
-
background-position: center;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
@media (min-width: 640px) {
|
|
343
|
-
.hero {
|
|
344
|
-
background-image: url('hero-tablet.jpg');
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
@media (min-width: 1024px) {
|
|
349
|
-
.hero {
|
|
350
|
-
background-image: url('hero-desktop.jpg');
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## Container Queries (Modern)
|
|
358
|
-
|
|
359
|
-
**Use Case:** Component-specific responsive behavior (not viewport-based)
|
|
360
|
-
|
|
361
|
-
```css
|
|
362
|
-
/* Define container */
|
|
363
|
-
.card-container {
|
|
364
|
-
container-type: inline-size;
|
|
365
|
-
container-name: card;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/* Query container (not viewport) */
|
|
369
|
-
@container card (min-width: 400px) {
|
|
370
|
-
.card {
|
|
371
|
-
display: grid;
|
|
372
|
-
grid-template-columns: 200px 1fr;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
@container card (max-width: 399px) {
|
|
377
|
-
.card {
|
|
378
|
-
display: block;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**Benefits:**
|
|
384
|
-
- ✅ Component adapts to parent width, not viewport
|
|
385
|
-
- ✅ Better for reusable components
|
|
386
|
-
- ✅ More predictable behavior
|
|
387
|
-
|
|
388
|
-
**Browser Support:** Modern browsers (2023+)
|
|
389
|
-
|
|
390
|
-
---
|
|
391
|
-
|
|
392
|
-
## Touch & Hover Interactions
|
|
393
|
-
|
|
394
|
-
### Touch Targets
|
|
395
|
-
|
|
396
|
-
**Minimum Size:** 44x44px (Apple HIG, WCAG 2.1)
|
|
397
|
-
|
|
398
|
-
```css
|
|
399
|
-
.button {
|
|
400
|
-
min-width: 44px;
|
|
401
|
-
min-height: 44px;
|
|
402
|
-
padding: var(--spacing-2) var(--spacing-4);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
.icon-button {
|
|
406
|
-
width: 44px;
|
|
407
|
-
height: 44px;
|
|
408
|
-
display: flex;
|
|
409
|
-
align-items: center;
|
|
410
|
-
justify-content: center;
|
|
411
|
-
}
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
### Hover vs Touch
|
|
415
|
-
|
|
416
|
-
**Detect Hover Capability:**
|
|
417
|
-
```css
|
|
418
|
-
/* Desktop (has hover) */
|
|
419
|
-
@media (hover: hover) {
|
|
420
|
-
.button:hover {
|
|
421
|
-
background: var(--color-primary-dark);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/* Touch devices (no hover) */
|
|
426
|
-
@media (hover: none) {
|
|
427
|
-
.button:active {
|
|
428
|
-
background: var(--color-primary-dark);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
---
|
|
434
|
-
|
|
435
|
-
## Performance Optimization
|
|
436
|
-
|
|
437
|
-
### Viewport Meta Tag
|
|
438
|
-
|
|
439
|
-
**Essential for Mobile:**
|
|
440
|
-
```html
|
|
441
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
**Without this:** Mobile browsers zoom out to fit desktop layout
|
|
445
|
-
**With this:** Mobile browsers render at device width
|
|
446
|
-
|
|
447
|
-
### Reduce Reflows
|
|
448
|
-
|
|
449
|
-
**Bad:**
|
|
450
|
-
```css
|
|
451
|
-
/* Causes layout recalculation */
|
|
452
|
-
@media (max-width: 767px) {
|
|
453
|
-
.element {
|
|
454
|
-
width: calc(100% - 20px); /* Reflow */
|
|
455
|
-
margin-left: 10px; /* Reflow */
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
**Good:**
|
|
461
|
-
```css
|
|
462
|
-
/* GPU-accelerated properties */
|
|
463
|
-
@media (max-width: 767px) {
|
|
464
|
-
.element {
|
|
465
|
-
transform: translateX(10px); /* No reflow */
|
|
466
|
-
opacity: 0.8; /* No reflow */
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
|
-
## Testing Checklist
|
|
474
|
-
|
|
475
|
-
### Device Testing
|
|
476
|
-
|
|
477
|
-
**Critical Devices:**
|
|
478
|
-
- [ ] iPhone SE (375px) - Smallest modern phone
|
|
479
|
-
- [ ] iPhone 14 (390px) - Standard phone
|
|
480
|
-
- [ ] iPad (768px) - Tablet
|
|
481
|
-
- [ ] iPad Pro (1024px) - Large tablet
|
|
482
|
-
- [ ] Desktop (1280px) - Standard desktop
|
|
483
|
-
- [ ] Desktop (1920px) - Large desktop
|
|
484
|
-
|
|
485
|
-
**Browser Testing:**
|
|
486
|
-
- [ ] Chrome (mobile + desktop)
|
|
487
|
-
- [ ] Safari (iOS + macOS)
|
|
488
|
-
- [ ] Firefox
|
|
489
|
-
- [ ] Edge
|
|
490
|
-
|
|
491
|
-
### Visual Testing
|
|
492
|
-
|
|
493
|
-
**Check for:**
|
|
494
|
-
- [ ] Text readability (min 16px on mobile)
|
|
495
|
-
- [ ] Touch targets (min 44x44px)
|
|
496
|
-
- [ ] Horizontal scrolling (should never happen)
|
|
497
|
-
- [ ] Image scaling (proper aspect ratios)
|
|
498
|
-
- [ ] Spacing consistency
|
|
499
|
-
- [ ] Navigation usability
|
|
500
|
-
- [ ] Form field usability
|
|
501
|
-
|
|
502
|
-
---
|
|
503
|
-
|
|
504
|
-
## Best Practices
|
|
505
|
-
|
|
506
|
-
### DO:
|
|
507
|
-
- ✅ Design mobile-first (default styles for mobile)
|
|
508
|
-
- ✅ Use relative units (rem, em, %, vw, vh)
|
|
509
|
-
- ✅ Test on real devices (not just DevTools)
|
|
510
|
-
- ✅ Use 3-tier breakpoints (mobile, tablet, desktop)
|
|
511
|
-
- ✅ Prioritize essential content on mobile
|
|
512
|
-
- ✅ Use touch-friendly targets (min 44x44px)
|
|
513
|
-
- ✅ Optimize images for each breakpoint
|
|
514
|
-
|
|
515
|
-
### DON'T:
|
|
516
|
-
- ❌ Use fixed pixel widths
|
|
517
|
-
- ❌ Design desktop-first (harder to simplify)
|
|
518
|
-
- ❌ Test only in DevTools (real devices behave differently)
|
|
519
|
-
- ❌ Use too many breakpoints (3-4 is enough)
|
|
520
|
-
- ❌ Hide important content on mobile
|
|
521
|
-
- ❌ Use hover-only interactions on touch devices
|
|
522
|
-
- ❌ Serve desktop images to mobile
|
|
523
|
-
|
|
524
|
-
---
|
|
525
|
-
|
|
526
|
-
## Quick Reference
|
|
527
|
-
|
|
528
|
-
**Breakpoints:**
|
|
529
|
-
| Size | Min Width | Target |
|
|
530
|
-
|------|-----------|--------|
|
|
531
|
-
| sm | 640px | Tablets |
|
|
532
|
-
| md | 768px | Small laptops |
|
|
533
|
-
| lg | 1024px | Desktops |
|
|
534
|
-
| xl | 1280px | Large desktops |
|
|
535
|
-
|
|
536
|
-
**Box Movement Patterns:**
|
|
537
|
-
| Pattern | Desktop | Mobile |
|
|
538
|
-
|---------|---------|--------|
|
|
539
|
-
| Stacking | Horizontal | Vertical |
|
|
540
|
-
| Merging | 3 columns | 1 column |
|
|
541
|
-
| Prioritizing | Show all | Show essential |
|
|
542
|
-
| Compressing | 48px spacing | 16px spacing |
|
|
543
|
-
|
|
544
|
-
**Touch Targets:**
|
|
545
|
-
- Minimum: 44x44px
|
|
546
|
-
- Spacing: 8px between targets
|
|
547
|
-
- Common: 48x48px (generous)
|
|
548
|
-
|
|
549
|
-
---
|
|
550
|
-
|
|
551
|
-
**💡 Remember:** Think in terms of box behavior (stack, merge, prioritize), not pixels!
|
|
1
|
+
# Responsive Design
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Adaptive layouts that work across all screen sizes
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Mobile-First Philosophy
|
|
8
|
+
|
|
9
|
+
**Core Principle:** Design for mobile, enhance for desktop
|
|
10
|
+
|
|
11
|
+
**Why Mobile-First?**
|
|
12
|
+
- ✅ Forces prioritization of essential content
|
|
13
|
+
- ✅ Better performance (load only what's needed)
|
|
14
|
+
- ✅ Easier to scale up than down
|
|
15
|
+
- ✅ Matches user behavior (60%+ mobile traffic)
|
|
16
|
+
|
|
17
|
+
**Implementation:**
|
|
18
|
+
```css
|
|
19
|
+
/* ✅ Mobile-first (recommended) */
|
|
20
|
+
.element {
|
|
21
|
+
/* Mobile styles (default) */
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (min-width: 640px) {
|
|
26
|
+
.element {
|
|
27
|
+
/* Tablet styles */
|
|
28
|
+
width: 50%;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (min-width: 1024px) {
|
|
33
|
+
.element {
|
|
34
|
+
/* Desktop styles */
|
|
35
|
+
width: 33.333%;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ❌ Desktop-first (avoid) */
|
|
40
|
+
.element {
|
|
41
|
+
width: 33.333%; /* Desktop default */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (max-width: 1023px) {
|
|
45
|
+
.element {
|
|
46
|
+
width: 50%; /* Tablet override */
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@media (max-width: 639px) {
|
|
51
|
+
.element {
|
|
52
|
+
width: 100%; /* Mobile override */
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Breakpoint System
|
|
60
|
+
|
|
61
|
+
### 3-Tier Standard Breakpoints
|
|
62
|
+
|
|
63
|
+
| Tier | Min Width | Target Devices | Common Resolutions |
|
|
64
|
+
|------|-----------|----------------|-------------------|
|
|
65
|
+
| **Mobile** | < 640px | Phones | 375px, 414px |
|
|
66
|
+
| **Tablet** | 640px - 1024px | Tablets, small laptops | 768px, 834px, 1024px |
|
|
67
|
+
| **Desktop** | > 1024px | Laptops, desktops | 1280px, 1440px, 1920px |
|
|
68
|
+
|
|
69
|
+
**Implementation:**
|
|
70
|
+
```css
|
|
71
|
+
:root {
|
|
72
|
+
--breakpoint-sm: 640px; /* Tablets */
|
|
73
|
+
--breakpoint-md: 768px; /* Small laptops */
|
|
74
|
+
--breakpoint-lg: 1024px; /* Desktops */
|
|
75
|
+
--breakpoint-xl: 1280px; /* Large desktops */
|
|
76
|
+
--breakpoint-2xl: 1536px; /* Extra large */
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Usage */
|
|
80
|
+
@media (min-width: 640px) { /* Tablet+ */ }
|
|
81
|
+
@media (min-width: 1024px) { /* Desktop+ */ }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### Extended Breakpoints (Optional)
|
|
87
|
+
|
|
88
|
+
**For projects needing more granularity:**
|
|
89
|
+
|
|
90
|
+
| Size | Min Width | Use Case |
|
|
91
|
+
|------|-----------|----------|
|
|
92
|
+
| xs | < 480px | Small phones |
|
|
93
|
+
| sm | 640px | Tablets |
|
|
94
|
+
| md | 768px | Small laptops |
|
|
95
|
+
| lg | 1024px | Desktops |
|
|
96
|
+
| xl | 1280px | Large desktops |
|
|
97
|
+
| 2xl | 1536px | Extra large screens |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Responsive Box Movement
|
|
102
|
+
|
|
103
|
+
**Core Concept:** Describe layouts in terms of box behavior, not pixels
|
|
104
|
+
|
|
105
|
+
### Stacking Pattern
|
|
106
|
+
|
|
107
|
+
**Desktop (Horizontal) → Mobile (Vertical)**
|
|
108
|
+
|
|
109
|
+
```css
|
|
110
|
+
/* Desktop: Side-by-side */
|
|
111
|
+
.container {
|
|
112
|
+
display: flex;
|
|
113
|
+
gap: var(--spacing-6);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Mobile: Stacked */
|
|
117
|
+
@media (max-width: 639px) {
|
|
118
|
+
.container {
|
|
119
|
+
flex-direction: column;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Visual:**
|
|
125
|
+
```
|
|
126
|
+
Desktop (> 1024px):
|
|
127
|
+
┌────────────┬────────────┐
|
|
128
|
+
│ Sidebar │ Main │
|
|
129
|
+
└────────────┴────────────┘
|
|
130
|
+
|
|
131
|
+
Mobile (< 640px):
|
|
132
|
+
┌────────────┐
|
|
133
|
+
│ Main │
|
|
134
|
+
├────────────┤
|
|
135
|
+
│ Sidebar │
|
|
136
|
+
└────────────┘
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### Merging Pattern
|
|
142
|
+
|
|
143
|
+
**Multiple Boxes → Single Unified Box**
|
|
144
|
+
|
|
145
|
+
```css
|
|
146
|
+
/* Desktop: 3 columns */
|
|
147
|
+
.grid {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: repeat(3, 1fr);
|
|
150
|
+
gap: var(--spacing-6);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Tablet: 2 columns */
|
|
154
|
+
@media (max-width: 1023px) {
|
|
155
|
+
.grid {
|
|
156
|
+
grid-template-columns: repeat(2, 1fr);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Mobile: 1 column */
|
|
161
|
+
@media (max-width: 639px) {
|
|
162
|
+
.grid {
|
|
163
|
+
grid-template-columns: 1fr;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### Prioritizing Pattern
|
|
171
|
+
|
|
172
|
+
**Important Content First, Secondary Content Hidden/Moved**
|
|
173
|
+
|
|
174
|
+
```css
|
|
175
|
+
/* Desktop: Show all */
|
|
176
|
+
.header {
|
|
177
|
+
display: flex;
|
|
178
|
+
justify-content: space-between;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.nav {
|
|
182
|
+
display: flex;
|
|
183
|
+
gap: var(--spacing-6);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Mobile: Hide nav, show hamburger */
|
|
187
|
+
@media (max-width: 767px) {
|
|
188
|
+
.nav {
|
|
189
|
+
display: none; /* Hidden by default */
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.nav.open {
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
position: fixed;
|
|
196
|
+
top: 0;
|
|
197
|
+
left: 0;
|
|
198
|
+
width: 100%;
|
|
199
|
+
height: 100vh;
|
|
200
|
+
background: white;
|
|
201
|
+
padding: var(--spacing-6);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.hamburger {
|
|
205
|
+
display: block; /* Visible on mobile */
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### Compressing Pattern
|
|
213
|
+
|
|
214
|
+
**Boxes Shrink, Maintain Relationships**
|
|
215
|
+
|
|
216
|
+
```css
|
|
217
|
+
/* Desktop: Generous spacing */
|
|
218
|
+
.section {
|
|
219
|
+
padding: var(--spacing-12); /* 48px */
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Tablet: Medium spacing */
|
|
223
|
+
@media (max-width: 1023px) {
|
|
224
|
+
.section {
|
|
225
|
+
padding: var(--spacing-8); /* 32px */
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* Mobile: Compact spacing */
|
|
230
|
+
@media (max-width: 639px) {
|
|
231
|
+
.section {
|
|
232
|
+
padding: var(--spacing-4); /* 16px */
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Scaling Pattern:** 2x (desktop) → 1.5x (tablet) → 1x (mobile)
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Responsive Typography
|
|
242
|
+
|
|
243
|
+
### Fluid Font Sizes
|
|
244
|
+
|
|
245
|
+
**Method 1: Breakpoint-Based (Simple)**
|
|
246
|
+
|
|
247
|
+
```css
|
|
248
|
+
/* Mobile */
|
|
249
|
+
h1 {
|
|
250
|
+
font-size: 2rem; /* 32px */
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* Tablet */
|
|
254
|
+
@media (min-width: 640px) {
|
|
255
|
+
h1 {
|
|
256
|
+
font-size: 2.25rem; /* 36px */
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* Desktop */
|
|
261
|
+
@media (min-width: 1024px) {
|
|
262
|
+
h1 {
|
|
263
|
+
font-size: 2.5rem; /* 40px */
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Method 2: clamp() Function (Fluid)**
|
|
269
|
+
|
|
270
|
+
```css
|
|
271
|
+
h1 {
|
|
272
|
+
/* min, preferred (scales with viewport), max */
|
|
273
|
+
font-size: clamp(2rem, 4vw, 2.5rem);
|
|
274
|
+
/* 32px minimum, scales between, 40px maximum */
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
h2 {
|
|
278
|
+
font-size: clamp(1.5rem, 3vw, 2rem);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
p {
|
|
282
|
+
font-size: clamp(1rem, 1.5vw, 1.125rem);
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Benefits of clamp():**
|
|
287
|
+
- ✅ Smoothly scales between breakpoints
|
|
288
|
+
- ✅ No media queries needed
|
|
289
|
+
- ✅ Better user experience (no jumps)
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Responsive Images
|
|
294
|
+
|
|
295
|
+
### Techniques
|
|
296
|
+
|
|
297
|
+
**1. Fluid Images (Default)**
|
|
298
|
+
```css
|
|
299
|
+
img {
|
|
300
|
+
max-width: 100%;
|
|
301
|
+
height: auto;
|
|
302
|
+
display: block;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**2. Picture Element (Art Direction)**
|
|
307
|
+
```html
|
|
308
|
+
<picture>
|
|
309
|
+
<!-- Desktop -->
|
|
310
|
+
<source media="(min-width: 1024px)" srcset="hero-desktop.jpg">
|
|
311
|
+
|
|
312
|
+
<!-- Tablet -->
|
|
313
|
+
<source media="(min-width: 640px)" srcset="hero-tablet.jpg">
|
|
314
|
+
|
|
315
|
+
<!-- Mobile (default) -->
|
|
316
|
+
<img src="hero-mobile.jpg" alt="Hero">
|
|
317
|
+
</picture>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**3. srcset (Resolution Switching)**
|
|
321
|
+
```html
|
|
322
|
+
<img
|
|
323
|
+
srcset="image-small.jpg 480w,
|
|
324
|
+
image-medium.jpg 768w,
|
|
325
|
+
image-large.jpg 1200w"
|
|
326
|
+
sizes="(max-width: 640px) 100vw,
|
|
327
|
+
(max-width: 1024px) 50vw,
|
|
328
|
+
33vw"
|
|
329
|
+
src="image-medium.jpg"
|
|
330
|
+
alt="Responsive image"
|
|
331
|
+
>
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**4. Background Images**
|
|
335
|
+
```css
|
|
336
|
+
.hero {
|
|
337
|
+
background-image: url('hero-mobile.jpg');
|
|
338
|
+
background-size: cover;
|
|
339
|
+
background-position: center;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@media (min-width: 640px) {
|
|
343
|
+
.hero {
|
|
344
|
+
background-image: url('hero-tablet.jpg');
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
@media (min-width: 1024px) {
|
|
349
|
+
.hero {
|
|
350
|
+
background-image: url('hero-desktop.jpg');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Container Queries (Modern)
|
|
358
|
+
|
|
359
|
+
**Use Case:** Component-specific responsive behavior (not viewport-based)
|
|
360
|
+
|
|
361
|
+
```css
|
|
362
|
+
/* Define container */
|
|
363
|
+
.card-container {
|
|
364
|
+
container-type: inline-size;
|
|
365
|
+
container-name: card;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/* Query container (not viewport) */
|
|
369
|
+
@container card (min-width: 400px) {
|
|
370
|
+
.card {
|
|
371
|
+
display: grid;
|
|
372
|
+
grid-template-columns: 200px 1fr;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@container card (max-width: 399px) {
|
|
377
|
+
.card {
|
|
378
|
+
display: block;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Benefits:**
|
|
384
|
+
- ✅ Component adapts to parent width, not viewport
|
|
385
|
+
- ✅ Better for reusable components
|
|
386
|
+
- ✅ More predictable behavior
|
|
387
|
+
|
|
388
|
+
**Browser Support:** Modern browsers (2023+)
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Touch & Hover Interactions
|
|
393
|
+
|
|
394
|
+
### Touch Targets
|
|
395
|
+
|
|
396
|
+
**Minimum Size:** 44x44px (Apple HIG, WCAG 2.1)
|
|
397
|
+
|
|
398
|
+
```css
|
|
399
|
+
.button {
|
|
400
|
+
min-width: 44px;
|
|
401
|
+
min-height: 44px;
|
|
402
|
+
padding: var(--spacing-2) var(--spacing-4);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.icon-button {
|
|
406
|
+
width: 44px;
|
|
407
|
+
height: 44px;
|
|
408
|
+
display: flex;
|
|
409
|
+
align-items: center;
|
|
410
|
+
justify-content: center;
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Hover vs Touch
|
|
415
|
+
|
|
416
|
+
**Detect Hover Capability:**
|
|
417
|
+
```css
|
|
418
|
+
/* Desktop (has hover) */
|
|
419
|
+
@media (hover: hover) {
|
|
420
|
+
.button:hover {
|
|
421
|
+
background: var(--color-primary-dark);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* Touch devices (no hover) */
|
|
426
|
+
@media (hover: none) {
|
|
427
|
+
.button:active {
|
|
428
|
+
background: var(--color-primary-dark);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Performance Optimization
|
|
436
|
+
|
|
437
|
+
### Viewport Meta Tag
|
|
438
|
+
|
|
439
|
+
**Essential for Mobile:**
|
|
440
|
+
```html
|
|
441
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Without this:** Mobile browsers zoom out to fit desktop layout
|
|
445
|
+
**With this:** Mobile browsers render at device width
|
|
446
|
+
|
|
447
|
+
### Reduce Reflows
|
|
448
|
+
|
|
449
|
+
**Bad:**
|
|
450
|
+
```css
|
|
451
|
+
/* Causes layout recalculation */
|
|
452
|
+
@media (max-width: 767px) {
|
|
453
|
+
.element {
|
|
454
|
+
width: calc(100% - 20px); /* Reflow */
|
|
455
|
+
margin-left: 10px; /* Reflow */
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Good:**
|
|
461
|
+
```css
|
|
462
|
+
/* GPU-accelerated properties */
|
|
463
|
+
@media (max-width: 767px) {
|
|
464
|
+
.element {
|
|
465
|
+
transform: translateX(10px); /* No reflow */
|
|
466
|
+
opacity: 0.8; /* No reflow */
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## Testing Checklist
|
|
474
|
+
|
|
475
|
+
### Device Testing
|
|
476
|
+
|
|
477
|
+
**Critical Devices:**
|
|
478
|
+
- [ ] iPhone SE (375px) - Smallest modern phone
|
|
479
|
+
- [ ] iPhone 14 (390px) - Standard phone
|
|
480
|
+
- [ ] iPad (768px) - Tablet
|
|
481
|
+
- [ ] iPad Pro (1024px) - Large tablet
|
|
482
|
+
- [ ] Desktop (1280px) - Standard desktop
|
|
483
|
+
- [ ] Desktop (1920px) - Large desktop
|
|
484
|
+
|
|
485
|
+
**Browser Testing:**
|
|
486
|
+
- [ ] Chrome (mobile + desktop)
|
|
487
|
+
- [ ] Safari (iOS + macOS)
|
|
488
|
+
- [ ] Firefox
|
|
489
|
+
- [ ] Edge
|
|
490
|
+
|
|
491
|
+
### Visual Testing
|
|
492
|
+
|
|
493
|
+
**Check for:**
|
|
494
|
+
- [ ] Text readability (min 16px on mobile)
|
|
495
|
+
- [ ] Touch targets (min 44x44px)
|
|
496
|
+
- [ ] Horizontal scrolling (should never happen)
|
|
497
|
+
- [ ] Image scaling (proper aspect ratios)
|
|
498
|
+
- [ ] Spacing consistency
|
|
499
|
+
- [ ] Navigation usability
|
|
500
|
+
- [ ] Form field usability
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## Best Practices
|
|
505
|
+
|
|
506
|
+
### DO:
|
|
507
|
+
- ✅ Design mobile-first (default styles for mobile)
|
|
508
|
+
- ✅ Use relative units (rem, em, %, vw, vh)
|
|
509
|
+
- ✅ Test on real devices (not just DevTools)
|
|
510
|
+
- ✅ Use 3-tier breakpoints (mobile, tablet, desktop)
|
|
511
|
+
- ✅ Prioritize essential content on mobile
|
|
512
|
+
- ✅ Use touch-friendly targets (min 44x44px)
|
|
513
|
+
- ✅ Optimize images for each breakpoint
|
|
514
|
+
|
|
515
|
+
### DON'T:
|
|
516
|
+
- ❌ Use fixed pixel widths
|
|
517
|
+
- ❌ Design desktop-first (harder to simplify)
|
|
518
|
+
- ❌ Test only in DevTools (real devices behave differently)
|
|
519
|
+
- ❌ Use too many breakpoints (3-4 is enough)
|
|
520
|
+
- ❌ Hide important content on mobile
|
|
521
|
+
- ❌ Use hover-only interactions on touch devices
|
|
522
|
+
- ❌ Serve desktop images to mobile
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## Quick Reference
|
|
527
|
+
|
|
528
|
+
**Breakpoints:**
|
|
529
|
+
| Size | Min Width | Target |
|
|
530
|
+
|------|-----------|--------|
|
|
531
|
+
| sm | 640px | Tablets |
|
|
532
|
+
| md | 768px | Small laptops |
|
|
533
|
+
| lg | 1024px | Desktops |
|
|
534
|
+
| xl | 1280px | Large desktops |
|
|
535
|
+
|
|
536
|
+
**Box Movement Patterns:**
|
|
537
|
+
| Pattern | Desktop | Mobile |
|
|
538
|
+
|---------|---------|--------|
|
|
539
|
+
| Stacking | Horizontal | Vertical |
|
|
540
|
+
| Merging | 3 columns | 1 column |
|
|
541
|
+
| Prioritizing | Show all | Show essential |
|
|
542
|
+
| Compressing | 48px spacing | 16px spacing |
|
|
543
|
+
|
|
544
|
+
**Touch Targets:**
|
|
545
|
+
- Minimum: 44x44px
|
|
546
|
+
- Spacing: 8px between targets
|
|
547
|
+
- Common: 48x48px (generous)
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
**💡 Remember:** Think in terms of box behavior (stack, merge, prioritize), not pixels!
|