Chapter practice task
Task: Make your portfolio fully responsive with a theme you can recolor in seconds
- Write your base styles for phones first.
- Add a media query at 768px that switches your services to two columns, and one at 1024px for three.
- Move all your colors, fonts and spacing into CSS variables on
:root. - Change the brand color variable and check that the whole site updates.
- Add a dark mode with
prefers-color-scheme.
By the end of this chapter
- You can write mobile-first media queries and choose sensible breakpoints
- You can store your design decisions in CSS variables
- You can add a dark mode with a few lines of CSS
Quick answers for this chapter
What’s mobile-first?
Writing styles for small screens first, then adding media queries for bigger ones.
Are CSS variables the same as Sass variables?
No. CSS variables work in the browser and can change live; Sass variables are replaced when the file is compiled.
How many breakpoints do I need?
Usually two or three. Add one wherever your design starts to look wrong.