Careeroza
Mobile-First
Mobile-First CSS
Write the base styles for small screens first, then add min-width media queries for larger screens. Phones then download and apply the least CSS, and layouts naturally grow instead of being squeezed.
/* base: phones */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
/* tablets */
@media (min-width: 600px) {
.grid { grid-template-columns: 1fr 1fr; }
}
/* desktops */
@media (min-width: 1024px) {
.grid { grid-template-columns: repeat(4, 1fr); }
}Checklist
- Add
<meta name="viewport" content="width=device-width, initial-scale=1">. - Use relative units and
max-widthinstead of fixed widths. - Images:
max-width: 100%; height: auto;. - Make tap targets at least 44×44px.
- Test with DevTools device mode and on a real phone.