Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The footer of a web site is often left as unused real state. I find the footer to be quite useful for adding further information about the site and links to relevant content. To make it easy to configure the footer area, I usually add a set of optional widgets in the footer. You can see them down here at the bottom. I added four different widgets here--Archives, Categories, Recent Comments, and Recent Posts-- but now that I've added the footer widgets, I need to make them responsive. If we look at this theme and resize the window, you'll see that as we resize it, the footer widgets automatically resize with it.
The problem of course is that at some point the footer widgets become almost unreadable because they're squished so tight together. What we need to do is apply media queries to handle the footer widgets once the screen gets too narrow. And what I want to do here is simply box each widget in its on 100% width box and then stack them one after the other. If we look at the footer widgets for the Developer Tools, you'll see why they do what they do.
Each of the widgets is contained inside a list item, and that list item has a percentage width, is floating to the left, and has a percentage margin to the right. As a result it'll rescale to a percentage of the total width of the screen. This also tells us the solution to our problem. To make the footer widgets stack one on top of the other, all we have to do is reset these three values. So I'll copy out the style, go into my style sheet, and down to my media queries at the bottom. I'll find the media query that affects all the content on the small screens, so this one at 719, and I'll go all the way to the bottom of that media query and paste in the style I just copied out from Chrome.
Now all I have to do is reset the width. So I will set the width to 100%, because I want it to spend across the whole page. I'll set float to none, because I don't want to content to float, and I'll also set margin-right to 0. Save this, reload the page, scale it down, and you'll see right at the breakpoint the footer widgets will now stack one on top of the other. But I need to add one more piece of style, because as you can see, the footer widgets don't have any space between them, so it's hard to see where one ends and the next begins.
So I'll go back in to my styles and margin bottom 2em, save it, reload it, and now there's a nice little space between each of the widgets. Of course, you can choose to change that value if you want to, but I think that the 2em value works fine. But there's one other piece of footer content in the site that you haven't seen yet. In addition to the footer widgets, there's some content that only kicks in at certain times.
In this post, you'll see it. It's right here at the bottom. We see three related posts. This is a custom function that's built into the theme that looks for three related posts to the current article based on when they were posted and based on the categories that are in this article. If there are not enough related posts then you'd simply don't see this box. And just like with the footer widgets, these boxes are responsive, so they resize with the window, but we've to give them a breakpoint too where we want to stack them one on top of the other.
That means we first need to find out how they work, so we use the Developer Tools to look at them, and we'll see, just like the footer widgets, each of these boxes is contained within a list item in an unordered list, and each has a percentage width floating to the left and a percentage margin to the right. So again, we copy out the style, paste it in, clean it up, and then we set the width to 100%, float to none, and the margin-right to 0, and finally, we should give it a margin on the bottom too.
So if I set the margin-bottom to 2em. Reload the page and now each of items stacks one on top of the other. Now if you want to be really clever, you'll notice that these two styles had the exact same style code, which means we don't have to repeat them like this. We can simply take the name, insert a comma in front of the first one, paste in the second one, and then we can delete the style, and now the footer sidebar list items and the related list items are handled by the same style.
Shorter code does the exact same thing. Making repeated side-by-side list items responsive is no more complicated than any other component on the site. You just have to consider how they're put together, so you can make the appropriate changes at the appropriate breakpoints throughout the site.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.