Start learning with our library of video tutorials taught by experts. Get started

CSS: Styling Navigation

Lab: Creating horizontal menus


From:

CSS: Styling Navigation

with James Williamson

Video: Lab: Creating horizontal menus

Welcome to our horizontal menus lab. This lab is going to be just a little bit different from the last one in the record that I'm going to give you a few parameters for our site's menu, but it's going to be up to you to decide exactly how you want to style it. So I have two files that we are going to be working on in our lab opened up here. I have got the index.htm and the main.css opened up. You can find these in the 04_09 directory, and I want to point out that the main.css is found in this _css submenu.
Expand all | Collapse all
  1. 3m 8s
    1. Welcome
      42s
    2. What you should know before watching this course
      1m 12s
    3. Using the exercise files
      1m 14s
  2. 35m 25s
    1. Organizing menus with lists
      4m 26s
    2. Ensuring accessibility
      9m 3s
    3. Using the nav element
      7m 30s
    4. Creating block-level links
      3m 8s
    5. Lab: Structuring navigation
      4m 11s
    6. Solution: Structuring navigation
      7m 7s
  3. 48m 42s
    1. Exploring link style considerations
      9m 2s
    2. Using global link styles
      9m 56s
    3. Styling link states
      10m 57s
    4. Indicating external links
      10m 4s
    5. Styling image links
      8m 43s
  4. 52m 5s
    1. Stripping default list styling
      4m 34s
    2. Defining link dimensions
      6m 0s
    3. Setting link styling
      3m 36s
    4. Aligning links vertically
      4m 11s
    5. Controlling link spacing
      2m 30s
    6. Styling menus with borders
      2m 32s
    7. Creating rollovers
      4m 45s
    8. Restricting link styling
      3m 31s
    9. Lab: Creating a vertical menu
      11m 44s
    10. Solution: Creating a vertical menu
      8m 42s
  5. 54m 58s
    1. Stripping list styling
      3m 35s
    2. Displaying links horizontally
      6m 14s
    3. Clearing floats
      6m 12s
    4. Controlling link sizing and spacing
      3m 11s
    5. Styling links
      7m 16s
    6. Creating rollovers
      5m 52s
    7. Indicating current pages
      4m 43s
    8. Controlling cursor states
      2m 46s
    9. Lab: Creating horizontal menus
      6m 45s
    10. Solution: Creating horizontal menus
      8m 24s
  6. 55m 35s
    1. Overview of dropdown menus
      1m 17s
    2. Structuring submenus
      5m 56s
    3. Styling submenus
      6m 4s
    4. Creating submenu rollovers
      3m 28s
    5. Positioning submenus
      5m 43s
    6. Controlling submenu display
      5m 5s
    7. Creating persistent hover states
      5m 53s
    8. Animating menus with CSS transitions
      6m 29s
    9. Lab: Dropdown menus
      6m 51s
    10. Solution: Dropdown menus
      8m 49s
  7. 58m 7s
    1. Creating CSS-only buttons
      8m 39s
    2. Creating special effects for buttons
      4m 2s
    3. Enhancing buttons with gradients
      7m 40s
    4. Overview of CSS sprites
      3m 30s
    5. Using CSS sprites for icons
      14m 30s
    6. Styling block-level links
      8m 38s
    7. Lab: Enhancing navigation with CSS
      5m 26s
    8. Solution: Enhancing navigation with CSS
      5m 42s
  8. 6m 29s
    1. Additional resources
      6m 29s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
CSS: Styling Navigation
5h 14m Beginner Nov 16, 2012

Viewers: in countries Watching now:

Join James Williamson, as he shows you how to create elegant menus, links, and buttons that help visitors navigate your site faster and more intuitively. The course covers creating structured navigation that is accessible and clean, styling links, and building horizontal and vertical menus with rollover effects. The last chapter reveals how to create stylish buttons with special effects and CSS sprites.

Topics include:
  • Organizing menus with lists
  • Creating block-level links
  • Styling links, link states, and image links
  • Defining link dimensions
  • Controlling link spacing in a menu
  • Creating rollovers
  • Clearing floats
  • Indicating current pages
  • Controlling cursor states
  • Building dropdown menus
  • Creating CSS-only buttons
Subjects:
Developer Web Web Design Web Development
Software:
CSS
Author:
James Williamson

Lab: Creating horizontal menus

Welcome to our horizontal menus lab. This lab is going to be just a little bit different from the last one in the record that I'm going to give you a few parameters for our site's menu, but it's going to be up to you to decide exactly how you want to style it. So I have two files that we are going to be working on in our lab opened up here. I have got the index.htm and the main.css opened up. You can find these in the 04_09 directory, and I want to point out that the main.css is found in this _css submenu.

So those are the two files that you are going to be working with. Now the instructions for this lab are at the very top of the main.css file. I am going to go through the steps for the instructions, and as I go through some of these individual ones, I am going to preview the finished version of the site menu so you can see what your target styling goal is. So the very first thing you want to do is browse through the structure of the HTML code, find a nav element with the ID pageNav, and really carefully look at that structures. So I am going to show you that.

In the source code, if I scroll down--and you don't want to go very far--right around line 18 or so you're going to find our site menu. Here we have a nav element that has an ID pageNav. So we are not using a class here, we are using an ID, and then we have unordered list with all the links inside of it. So it's a fairly simple structure very similar to what we're using earlier in the chapter, but to remember we do have that nav element, and as you begin to write selectors you're going to want to remember the ID of it, and you're going to really examine the structure so that you know how to write your selectors.

Now, the next thing that you want to do is you want to scroll down and find the styles that apply to the pageHeader h1 element. I am going to show the finished site layout so I can show you what I'm talking about here. The h1 is being styled as the Roux Academy logo here in the upper left-hand corner of our page layout. As you can see, the menu sits just to the right of that nestled at the very top of the page. So obviously, you're going to need to familiarize yourself with how that header is being styled so that when you style the menu those two items are working together.

Now to find those styles there in main.css, and I am just going to scroll down and show you where these are. It takes a little while to get down to them, but they are right here on line 216. They are header styles. There's not a lot going on there. There are only two selectors, but there's a lot of valuable information such as the width of the h1 that you're going to need to know about as you begin styling your menu. Now the nav styles themselves is individual styles you will actually write those right here at about line 233 just below that. Scroll back up here.

Now that you know the sections that you are going to be affecting and sort of where you are going to be writing your code I want to go over these steps to build the actual menu itself. Now unlike the previous labs where I've given you step-by-step instructions on exactly how to build it, I am just going to go give some parameters and give you some the values of the colors that are used, but other than that, I am going to totally leave it up to you to style the menu the best way that you see fit. Now these parameters are just below this. I am going to talk about them by looking at the actual menu itself.

So I am not going to spend a lot of time here, but when I reference colors if you come back into these instructions you'll find those color values right in here for each one of these steps. You can just copy and paste those colors, or you can certainly come up with your own color scheme. So here's what you'll need to do. The menu needs to appear just to the right of the Roux Academy logo, and it needs to go ahead and stretch all the way out for the remainder of the layout. Now this is the fixed with layout, meaning it's been designed to fit a specific width, in this case, 960 pixels.

You want to take a look at the body element, understand how much space you have, and then use that to determine how wide the menu should be. Now the background color of the menu is a very dark color, almost black. The RGB value is in the steps as I mentioned, but I'm also using an Alpha setting here, which is the semi-transparency. So that's one of the reasons why we can see the background image behind it. So take a look at those. Now if you want to change that and do something different with the menu, feel free. The next thing you'll need to do is you are going to want to space these menu items out so that it stretch almost across the entire menu.

If you want to add a little bit more space or have less space, that's totally up to you. It's whatever your personal preference is going to be, but remember, you want to have at least enough room to where it's very easy for somebody to go through the menu and select them, and then they know exactly what they're looking at when you do that. I used white text, and then I used the orange color for a rollover. If you want to change those, you can. I have also made all of the link text lowercase. You want to make it slightly smaller than the default text size, and it also needs to center vertically within the menu.

I've also added a little bit of padding to the links so that not only do I have enough active space on either side of the link, but later on when I show you guys the current page indicator you've got enough room to make that sort of tab look that we are going to be doing here as well. Also, you want to make sure that no background image shows up. Remember, we have the default diagonal pattern that shows up in all links, so you're going to want to disable that for your rollovers. Also, I've got a current page indicator that you're going to need to build, and I am just going to click through these different pages so you can see that current page indicator.

It's kind of like a tab shape. So I used a background color that's very close to white with an Alpha transparency, and notice that I have also changed the text color to black. I am rounding off the top corners, and as you can see, the cursor is not displaying, so I've turned the cursor back to that default cursor for those particular links. Remember that getting this current page indicator to work is actually a two-part process. Not only do you have to write the styles for it, but you're going to have to go into each of these individual pages and apply to your appropriate class or ID, depending upon which you choose to go with for that particular page.

I do realize it's going to be a little harder than your previous labs, but I really wanted in this lab for you to experience what it's like to have to plan and execute a menu within a much larger site. Don't forget you can open up the files located in the finished default folder and take a peek at the finished code if you're stuck and also be sure to watch the solutions movie where I explain why I wrote the menu styles the way that I did.

There are currently no FAQs about CSS: Styling Navigation.

Share a link to this course
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.
Upgrade now


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.

Upgrade now

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

Congratulations

You have completed CSS: Styling Navigation.

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


OK
Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com and our online training library:

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

   
submit Lightbox submit clicked