Using media queries to alter a design
If you’ve read, and at least partially understood, what we have been through so far in this chapter, you should be ready to start using media queries in earnest.
I’d suggest opening the index.html
file and the associated index.css
file from the Start
folder of this chapter’s code. Then try and add some media queries to alter some areas of the page at certain viewport widths. Let’s make a couple of changes together and then you can practice some of your own.
Let’s look at the header section of what we have currently (viewport around 1200 px wide):
Figure 3.3: On wider viewports, what we have in the browser doesn’t match the design
And here is the layout we are trying to achieve:
Figure 3.4: The design calls for a different layout at wider viewports
We need to keep the design as it is for smaller viewports but amend it for larger ones. Let’s start by adding a media...