Joystick Junkies: Responsive (Lab 6)
Related Lessons
This is Lab 6 in Developing Web Pages (BUS1880) and Web Fundamentals (CSCI1450). Before you start Lab 6, be sure you have studied and completed the exercises in the Slideshow for Module 6.
The objective of this lab assignment is to learn the basics of responsive design, including the viewport meta tag and media queries, while adapting a website for different screen sizes.
This lab requires that you have completed Lab 2, Lab 3, Lab 4, and Lab 5. Beyond that, all the code you need is provided here.
Jump to:
- A. Add the Viewport Meta Tag
- B. Add Media Queries
- C. Adjust Fonts and Spacing for Tablets
- D. Make Adjustments for Smartphones
- E. Check All Pages at All Widths
- F. Check Your Template
- Checklist for Grading
At the end of Lab 6 you will have three different versions of Joystick Junkies: desktop, tablet, and smartphone.

A. Add the Viewport Meta Tag
Add the viewport tag to all three HTML files between <head> and </head>, before your title. Place it underneath the other <meta> tag. Here is the code so you can copy and paste it.
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />

B. Add Media Queries
Let’s start by adding our two media queries. The top one is for tablets, and the bottom one is for smartphones.
Carefully copy the media query code below and paste it at the bottom of the style.css file. The media queries must go at the bottom of the page because they will override the other CSS for the desktop.

C. Adjust Fonts and Spacing for Tablets
Adjust the Heading Font Sizes
We need to adjust the heading font-size for mobile. Add CSS in the media queries to change the font-sizes as follows:
| Heading | Desktop | Tablet | Smartphone |
|---|---|---|---|
<h1> | 3.5em | 2.5em | 2em |
<h2> | 2em | 1.5em | 1.5em |
<h3> | 1.7em | 1.3em | 1.3em |
Check the font sizes in a browser. You should see smaller sizes in the tablet and smartphone screen widths.
Main Section on Tablet Size
Take a look at the tablet size for mobile. (See the screenshot below.) It looks pretty good, except for one thing — the text is too close to the edge on the main section and the footer. Make both of these changes in the media query for tablets:
Step 1. Add a selector for main and footer.
Step 2. Add a width of 90%.
Check and double check your curly braces. An extra or missing curly brace will break your CSS.


Before

After
On a side note, in Lab 5, we added a 40% max-width to the floating images. Adding a max-width to floated images is a good trick for mobile. Without a max-width, the images will go off the viewport on smartphones.
D. Make Adjustments for Smartphones
In the next set of steps, we are going to make the following changes for only the smartphone size. Since these changes are only for the smartphone size, we will put the CSS into the media query for smartphones. Here is a list of changes we are going to make:
- Change the text arrangement in the hero image. As you can see below, it is too large and the text is wrapping.
- Remove the photos with
display: none. These particular images don’t add enough value for smartphone screen sizes. - Change the text box position on the Gaming Systems page.
- Change the navigation style to one that is mobile-friendly.

Adjust Text on the Hero
In the media query for smartphone sizes:
Step 1. Create a selector for the .home-hero class. Set the height to 125px. This will override the height we added previously for tablets.
Step 2. Create a selector for h1 elements inside of the hero image (.home-hero h1).
- Add a height of 125px.
- Add a font-size of 1.5em.
- Add 45px of padding to the top.

Check in a browser and compare it to the screenshot below.

Remove Unnecessary Images
The photos we added to the Home and Top Games pages don’t add enough value for small screens. Let’s remove them. Add this code in the media query for smartphone sizes.
Step 1. Add a new selector for .float-right, .float-left
Step 2. Add the display property with a value of none.

Check in a browser to make sure the images are still in place on the tablet and desktop sizes, but disappear on the smartphone size.

Text Box Position on the Gaming Systems Page
On the Gaming Systems page, the text box needs adjustment. We’ll change the text box to full width. To do that, we need to override the values we added to the .text-box class. Work in the media query for smartphones.
Step 1. Add a selector for .text-box inside of the smartphone media query.
Step 2. Override the float on the text box with float: none
Step 3. Override the max-width of 40% with max-width: 100%
Step 4. Override the inline display with display: block

Mobile Navigation
Last, but not least, we are going to change the navigation so it is smartphone friendly. Work in the media query for smartphones.
Step 1. Add a selector for nav ul
- Add padding of 0
- Add margin of 0
Step 2. Add a selector for nav li inside of the smartphone media query.
- Change the display property to
block - Add .5em padding to the top and bottom, and 1em of padding to the left and right
- Add a border-bottom that is solid, with a width of 1px, and a color of gray. (Remember you need three values for a border.)

E. Check All Pages at All Widths
Check all three pages (Home, Gaming Systems, and Top Games) at all three widths (desktop, tablet, and smartphone) before moving on.

F. Check Your Template
Done with Joystick Junkies! In addition to checking your Joystick Junkies website, I will be making one last check of your website template this week. Here are some common file name problems you should fix.
Check Template Folders and Files
- Make sure the HTML file is named “index.html” instead of “template.html.” The reason for that is so that when you copy your template for upcoming labs, you already have an index.html file.
- You should only have two files in your website template: index.html and style.css. If you have other files, move them somewhere else. Everything in the template folder will be copied to your new websites.
- Check to make sure that your folder and file names are all lowercase.

Check Template in Browser
Your final template will look like this. Your colors and fonts will be different.

Problems with Your Template
Since you will start the Module 7 lab by copying your template, it is important to make sure your template is in good shape. Otherwise you will not have the right starting point for ongoing lab assignments.
Need a fresh start? If you have a lot of missing code or major gaps in your template, I have a blog post with all of the template work on one page. Go to this link:
https://webdevstudents.com/making-a-website-template
Note: If you have been keeping up with the template work and only have a few problems, I’ll help you find those. Either email it to me as a zip file or put a note in the Assignment Folder.
Checklist for Grading
From the Module 6 Slideshow
When you worked through Module 6, you added more to your website template. The template work will be graded as part of this lab.
Joystick Junkies Lab
Now you know how to make your site responsive! Move on to Lab 7 to learn about tables and forms.
Need Help?
Using AI for coding is not allowed in this course, so if you get stuck simply Make an Appointment for office hours. In addition, if you run into a bug as you are working, you may email your websites folder to me at susan.metoxen@saintpaul.edu.
