Watch every course in the library with a membership.
Each course includes high-quality videos taught by expert instructors.

Start Your Free Trial Now

Make the menu responsive Build Wordpress Themes

WordPress's default Underscores theme already has the code for making a responsive menu. This scales… Show More

WordPress: Building Themes from Scratch Using Underscores

with Morten Rand-Hendriksen

Video: Make the menu responsive Build Wordpress Themes

WordPress's default Underscores theme already has the code for making a responsive menu. This scales the menu to a mobile-friendly version automatically. However, the mobile version is simply a copy of the full-sized menu, squished down. In order to improve the menu appearance, this video will demonstrate adding styles to your media query stack menu items vertically, instead of horizontally, when viewed from a small screen.
Expand all | Collapse all
  1. 10m 55s
    1. Welcome
      1m 4s
    2. What to know before you start this course
      2m 40s
    3. How this course and the lesson files work
      3m 12s
    4. Introducing Simone: A preview of the final project
      3m 59s
  2. 21m 28s
    1. Installing and running WordPress on your computer
      3m 53s
    2. Getting and installing Underscores
      4m 11s
    3. Installing WordPress Theme Unit Test data
      4m 18s
    4. Installing the Developer plugin
      2m 58s
    5. Installing and setting up NetBeans or another IDE
      6m 8s
  3. 16m 15s
    1. Designing for mobile, content, and style
      4m 52s
    2. How do WordPress themes work?
      4m 48s
    3. Understanding the WordPress template hierarchy
      2m 19s
    4. Underscores: An overview
      4m 16s
  4. 37m 5s
    1. Setting up style.css
      4m 47s
    2. Configuring baseline settings and functions
      6m 6s
    3. Enabling custom fonts and font icons
      5m 44s
    4. Applying global styles
      5m 11s
    5. Styling basic layout components
      6m 19s
    6. Making the site layout responsive
      8m 58s
  5. 23m 18s
    1. Styling the default header
      6m 25s
    2. Hiding the site title and tagline
      5m 32s
    3. Adding an optional header image function
      5m 23s
    4. Placing the header image behind the site title
      5m 58s
  6. 40m 55s
    1. Setting up menus
      3m 12s
    2. Styling the menu
      7m 42s
    3. Using Superfish for accessible menus
      8m 0s
    4. Making the menu responsive
      7m 3s
    5. Creating a custom social media menu
      5m 51s
    6. Styling the menu with icons from Font Awesome
      9m 7s
  7. 18m 9s
    1. Adding the search form
      6m 27s
    2. Adding the search icon
      6m 55s
    3. Adding show/hide functionality to the search form with jQuery
      4m 47s
  8. 33m 20s
    1. Adding a widgetized area to the footer
      7m 10s
    2. Using the Monster widget plugin to test all widgets
      2m 11s
    3. Styling the footer
      3m 6s
    4. General widget styling
      5m 33s
    5. Adding custom styles to specific widgets
      7m 34s
    6. Using Masonry to make footer widgets responsive
      7m 46s
  9. 54m 49s
    1. Changing the Single Post Template content structure
      5m 54s
    2. Changing the output of meta elements
      7m 2s
    3. Styling the Single Post Template
      7m 57s
    4. Making post meta responsive
      6m 21s
    5. Styling blockquotes
      5m 39s
    6. Creating pull quotes and pull images
      5m 1s
    7. Working with image captions
      4m 27s
    8. Working with image galleries
      4m 57s
    9. Single-post navigation
      7m 31s
  10. 30m 23s
    1. Working with the comments template
      8m 42s
    2. Using Gravatars in comments
      2m 42s
    3. Styling comments
      7m 26s
    4. Highlighting post author comments
      3m 36s
    5. Styling the comment form and messages
      7m 57s
  11. 18m 43s
    1. How do featured images (post thumbnails) work?
      2m 57s
    2. Defining featured image sizes
      3m 30s
    3. Generating new featured images with a plugin
      1m 46s
    4. Adding featured images to a template
      5m 7s
    5. Styling the featured image
      5m 23s
  12. 1h 2m
    1. The index template hierarchy
      2m 21s
    2. Customizing and styling index templates
      10m 10s
    3. Displaying excerpts or full content on index pages
      3m 6s
    4. Adding a custom Read More link
      3m 48s
    5. Adding featured images
      4m 0s
    6. Creating custom pagination navigation
      6m 4s
    7. Highlighting Sticky Posts
      2m 55s
    8. Creating custom post format templates
      5m 30s
    9. Highlighting the most recent post in the index template
      7m 22s
    10. Embracing modular design
      2m 29s
    11. Working with archive.php
      5m 54s
    12. Customizing the search results and the 404 template
      8m 28s
  13. 9m 7s
    1. Styling pages
      3m 4s
    2. Creating custom page templates
      6m 3s
  14. 4m 30s
    1. Adding editor styles to match front-end styles
      4m 30s
  15. 2m 20s
    1. Further learning
      2m 20s

please wait ...
Making the menu responsive
Video Duration: 7m 3s 6h 23m Advanced


WordPress's default Underscores theme already has the code for making a responsive menu. This scales the menu to a mobile-friendly version automatically. However, the mobile version is simply a copy of the full-sized menu, squished down. In order to improve the menu appearance, this video will demonstrate adding styles to your media query stack menu items vertically, instead of horizontally, when viewed from a small screen.

View Course Description

Ready for your next WordPress challenge? Learn how to build more complex custom themes using the _s (aka Underscores) starter theme. Morten Rand-Hendriksen takes you from basic layout and customization to enabling advanced responsive design and accessibility features. He reinforces the basics lessons with DRY (don't repeat yourself) development practices and a structured approach that will help you build WordPress themes that meet modern standards. Plus, he'll explore core concepts like understanding the WordPress template hierarchy, creating functions, adding custom JavaScript, applying styles, and more.

Topics include:
  • Installing WordPress, Underscores, plugins, and NetBeans
  • Designing for mobile, content, and style
  • Setting up the basic theme
  • Building a custom header
  • Designing responsive, accessible menus
  • Adding a custom search form
  • Using and styling widgets
  • Adjusting the Single Post Template
  • Working with comments, featured images, index templates, and static pages
  • Adding editor styles to match front-end styles
WordPress underscores

Making the menu responsive

Now we have a menu that matches our design and is accessible, but we're not quite done yet. Because, you'll remember, when we scaled down the width of our screen to 600 pixels or lower, underscores automatically swaps out the menu for a mobile friendly menu that's triggered by this menu button here. The way this works is, when you get to this point there's a media query that automatically hides the menu and then there's a JavaScript attached to this menu button that when you click on the menu button the menu is revealed.

That way you have a simple way of interacting with the menu on mobile devices. The problem is, right now the menu still looks like a regular menu it's just been squished into a box. Now we need to add some additional styles in our media query. So that we can change the behavior of the menu to suit smaller screens, and that means primarily that we want all the menu items to stack vertically instead of horizontally, and that we want all the sub-menu items to appear at all times. But most of this work can be done with CSS.

So first, let's take a look at what is already happening. I'll go to style.css, and here, you all remember that the menus are under 5.2, so I'll search for 5.2. Here, we have the menu as we built it, and when I scroll down to the bottom of the menu, you'll see there's a small section here called small menu. Here we have the menu toggle as it appears when we're at a larger screen you'll see display is set to none. And then, within the media query that only kicks in for screen widths that are smaller than 600 pixels, the menu toggle is set to display, and our main navigation is set to height.

That way, when we scale down the window, the main navigation goes away and only when you click on the button does the JavaScript kick in, and so switch, this display none to a regular display, so we can see the content. Now what we want to do is change these styles so that we can control the menu better. If you go to the code-snippets for this movie, you'll see the code-snippets start off with the same media query, and at the very top, we have menu toggle, main navigation toggled nav menu, and also main navigation UL.

And if we go back to our existing style sheet, you'll see here we have menu toggle. Main navigation toggle nav menu and main navigation you out. First, I am going to to replace the styles that are in the current style sheet with these ones form the code snippets. What we're doing here is changing the menu toggle button so that it matches the overall design. I'm also using this separate style to change the appearance of the button once it's clicked, so that it's clear that it's been clicked.

And, I'm doing that by adding a border above the menu so you can see a clear separation. And finally, I'm changing the main navigation UL a little bit by adding left of zero. Because in the regular menu, we have a padding left and we need to get rid of it. Now I can save style.css, and go back to my page and reload it. Now I need to scale it down a bit, and here you see now, the menu button matches our overall menu. And when I trigger it, I get a nice line which separates the menu button from the actual menu.

So now we have the menu button working the way we want. The next step is to re-style the entire menu. And here, if you look at the code snippets you'll see I've created new styles for every single element. Because the mobile menu behaves completely differently from the regular menu so every single style has to be overridden. So here I can simply copy out all of these styles and I'll just paste them in here within the media query. Save it. Go back and reload the page. And now when you scale down the size of the window.

You see here we have a proper mobile menu. Each of the menu items lists vertically and they have nice large areas to click on. But there's still a problem. If we scroll down to one of the menu items that has sub-items, you'll see that the drop down effect still happens and that's in spite of our style sheet telling it not to. And this is because of Superfish. Because we're telling Superfish to override any style sheet and add in proper drop-down behavior, so it's doing that even on our mobile menu.

So what we need to do to get our mobile menu to work properly, is tell Superfish that if the screen width is less than 600 pixels, it be working on the menu at all. This should just leave it alone. This requires a change in the JavaScript settings for Superfish. And if you go to the code snippets you see here I have an alternate code for Superfish settings. You see it's much longer, so here I'm going to copy out this code. Go back to my theme. Go to JS, and Superfish settings. And I'll simply replace the code that we have here, with the new code.

So what's happening here is I'm defining a break point at 600 pixels. I'm still targeting the same area, but then I'm saying; if the document widths, so the width of the entire document is bigger than or equal to the break point of 600, then run Superfish as normal. That means when you load up the page, if your screen is small, you won't load super fish, but if you load up the page in a larger screen, super fish will load. The problem is, we also have to check whether or not the window is being resized, because someone might resize the window and we have to trigger this to happen when the window is resized as well.

So therefore we have a second function that says, on window resize, if the document with is bigger than the break point and the super fiche is currently not enabled, then start Superfish. If on the other hand the document width is smaller than the break point, then run the destroy function on superfish so that superfish disengages. Now I can save superfish settings with these new more conditional statements. Go and reload the page again.

And first I'll reload it in full width and make sure that superfish still works and you can see it does thanks to those delays. Then I'm going to resize my window and open my menu. Ando now you see the drop down elements appear by default, and they're also indented thanks to our styles. So they're easy to navigate. And if I scale back up again, you'll see superfish reengages. Then I have to test what happens if I load up the page from a small screen. So here I've loaded it up from a small screen. And again when I open the menu, it works properly as a mobile menu.

And when I scale up, Superfish engages, and then it will disengage again when I scale down. Then now by combining some media quarries that style the menu for the mobile screen with a custom function for Superfish, we have a fully responsive menu that is also fully accessible and matches our designs.

There are currently no FAQs about WordPress: Building Themes from Scratch Using Underscores.






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed WordPress: Building Themes from Scratch Using Underscores.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.