Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In our final lab we are going to take the Roux Academy website and create dropdown menus for several of the main navigation links. Though Roux Academy dropdowns are going to be a little different from the dropdowns that we built in the previous exercises, it's been pretty common when we do a lab that you're building something that's almost exactly or identical to what you're building in a previous exercises. And in this lab, I wanted to stretch you a little, I wanted to take you a little outside of your comfort zone and say, okay, you know the techniques. Now let's see if you can make them work in a slightly different way.
So let me show you what I mean. In the Roux Academy website, when I start to mouse over these top-level items, you'll notice we have dropdown menus for several of these that show up. But instead of showing up as a vertical menu like we did in our exercises, these are showing up just like another horizontal menu. They are just sort of underneath that. There's a little bit more to these, let me show you what I mean. If I click on say the programs page to go to the programs, here are the options in the programs menu submenu. But when I mouse off of it, it doesn't go away, it persists, which is perfect, that's exactly what I want, because if somebody's within the program section, I want them to be able to go up and see what their options are.
Now in terms of these menus persisting on their section pages, I am just going to talk about that a little bit when we get into the solution of the movie. So let's jump in and take a look at our lab instructions now. I have the index.htm file, as well as the main.css file open from the 05_09 directory. Remember that the main.css file is actually in the _css directory. We've got a few steps here. The first thing that the steps are telling me to do is what we just did. Basically, open the finished file, preview it in the browser, play around with the menus for a while, get an understanding of how they're positioned, what they look like, what kind of transition are evolved so that you've get a better idea of what you are going to need to do in terms of styling.
And then the next thing I'm asking you to do is to take a look at the HTML of the sites pages and really become familiar with how the submenus are structured and how classes are assigned. We are going to take a look at that once we're through all the steps. Here are the lab steps. I am just going to browse through these. First thing you want do is scroll down in the main.css file and find the dropdown menu styles. They are around line 252 or so depending upon which code editor you might be using. I need you to write a selector that's going to target the submenus. I am not telling you what selectors are right, you are going to have to figure exactly how to target those submenus based on the structure of html.
If you want to, you can use the surrounding selectors to kind of give you a hint. Now here's what I need you to do within that selector. You need to turn floating off, you need to set the background to this semi-transparent white color, and I have provided you with that value. Figure out how wide the submenu needs to be, based on where it's going to be located and then assign that value, set its height to Auto so that the contents are actually controlling the height of the submenus. And then I want to use positioning to start the submenu way off the page. I have given you -9000 pixels, but you can choose whatever you want to.
And then I bring it back to 45 pixels from the top of the parent nav element. You should also disable any margins. The next think you are going to do after that is you are going to use the structure of the top-level menu and the submenus. You are going to use that structure to write a selector that repositions the submenu to align with the nav element when the submenus top-level menu item is hovered over. So you'll need to write that selector, and you'll need to trigger that. Then using opacity, fade in the submenu as a trigger, and I want that to animate. You want to fade those submenus in as they are triggered with the top level menu items.
Inside the submenus themselves, that default rollover color for links of orange is very hard to read against that white background. So I am going to change it to one of the other site's other colors, which are sort of a darker lavender color, and I have given you that color right there. So you're going to go in to the submenus and change that rollover color for the submenus themselves. The last thing I want to do is just sort of observe test those dropdown menus and take a look at what I was talking about earlier. When you navigate to one of those sectional pages that has a set of submenu links, that submenu is going to persist until you hover over the nav bar again.
The top level unordered list has a class of topmenus, very similar to what we are doing earlier, and then all of the submenus also have that class of submenu as well. Something that's very important, it's not really going to have any bearing on the way you write your styles, but for that last step where you are going in and you are really sort of taking a look at the persistence of the submenus. I am going to open up one of those files, I am just going to go ahead and open up admissions, which is one of the sections that does have a submenu, and when I go down into admissions, I want you to notice that not only does the link have a class of current, but the list item has a class of current as well.
So as you are looking through those rules to try to determine how that menu persists when you're not browsing over it and how it goes away when you browse back over the nav bar, pay attention of that, that's a very important clue. Another thing as you go through the rules down here--and I am just going to scroll down to show you where these dropdown rules are going to go, as I mention around line 263-- you are going to see that a lot of these rules are already kind done for you. I have got a lot of selector already written and in place.
And the reason for that is I really wanted you to focus on the three most important tasks for dropdown menus and the ones that are likely to be newest for you. Number one is overriding the default menu styles, number two is properly positioning the submenus and then finally controlling the dropdown display. So those are the things I really want you to focus on, and that's particularly what your tasks are targeting. And as always, be sure to watch the solutions movie once you finish to compare your finished menus with mine.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 100173 Viewers
56 Video lessons · 113180 Viewers
71 Video lessons · 82048 Viewers
131 Video lessons · 39370 Viewers
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.