Viewers: in countries Watching now:
Join Joseph Lowery in Site Navigation with CSS in Dreamweaver as he explores current design trends in site navigation and shows designers and developers how to create robust CSS-based navigation. The course shows how to convert HTML lists to graphical controls that integrate seamlessly with an existing site design, and how to build menus with a wide range of navigation options, all in standards-compliant CSS. Exercise files accompany the course.
In this video, we are going to go from this inserted Spry vertical menu, which looks like this by default, to this vertical menu, which doesn't look anything like it at all. Are you up for the challenge? Let's get started. So I have now opened my mission.htm file from the Chapter 2 exercise files and we are ready to start doing some styling here. I am going to start by opening up the CSS Styles panel, and at the moment going into Current. And let's start by getting rid of this outer border that you see around here.
We don't need that at all. So I'll start by just selecting one of the Spry menu items, and that will bring into current mode in number of our Spry styles. Now you'll notice that there are a couple of rules that have the same selector but different properties assigned. The Spry Styles setup as it is by default tends to do this so that it can separate certain design styles like borders and font colors and the like that you see here into one area and other more structural things like font size and margin and padding in another.
Sometimes you have to look in two places to find the property that you want to modify. In this case, what we want to do is just go ahead and get rid of the border here. Now I could either delete it, or as I am going to do here, just disable it. And when I am working with Spry styles, I actually prefer to go to the All mode and use the Spry.css that I see there. It's laid out pretty logically and you can go actually from the outside of the menu in, as I like to work. So now we are going to go ahead and try to bring this menu more into keeping with the size and the look and feel that we are aiming for, and let's change the font size of the list items. And for that, we will go to ulMenuBarVertical li, and I'm going to click Edit Rule here to open up the CSS Rule Definition dialog box, and then go to the Type category, so I can choose a font family.
And I will choose Georgia which is used throughout this site, and then modify the font size from 100% to 2 em. I want to show you a quick trick. When you're working with the CSS Rule Definition dialog box, if you put in the unit measure right after the value, and then press Tab, Dreamweaver will update the unit measure list for you. Okay, we are finished with that, and now as you can see here, that brings our navigation, makes it quite large. And wait until you see the subnavigation. Even bigger. We will of course address that as we go forward.
Now one of the structural things that I notice is the subnavigation is overlapping the primary navigation, and I want to move that over and down, so let's attack that now. And that's going to be in the very next Rule that you see listed here, ulMenuBarVertical ul. Let's change the margin here from -5% and so forth to 0, 0, 0, 100%, which will put it to the right there. And if I try it, you can see that it is lined up just to the right.
Now we also need to make some other adjustments. I'm going to change the overall width of it from 8.2 ems to 6 ems to bring that down in size a little bit. Now you won't see that change in size right away, because the font size is so large. I am also going to add a background color to it, and I want to make sure that I scrolled down enough so I can sample my tan area here. And I'll just go ahead and type in background-color, press Tab so I get my color pickers, and I can open that up and with the eyedropper sample that color.
Now you will have to do this in a number of places in order to get that effect. I still want to move this menu item over just a bit, so I'll have to go to the following rule, which has the position property 'left' that you see here, and now instead of 0 I am going to make that 5 pixels instead. And once that's locked in, now you can see that there is a little bit of a separation there. Okay, so most of our structural work is done. Now, it's time to tackle the font size in the submenu.
So for this, it's the rule that follows the last one we worked on, and here we want to add a couple of properties. We are going to go ahead and change the font size and bring that down pretty radically to 0.5 em. Now if I go ahead and just preview that now, you will notice that the font size has changed radically, which is great, but I still have a wrapping problem. So I am going to go ahead and use a little-known CSS property called white-space to allow me to stop that wrapping from happening.
So just type in 'white-space' and then from the dropdown list, choose nowrap. So now if I take a look at it, I have Northern California, Central, and Southern-- each of them in a single line. Now this is one of the other places that I need to add in that background color, so I am going to go ahead and type in 'background-color', press Tab, and once again sample from the lower-left. All right! It's time to bring in the background image and adjust the padding so that the text sits neatly on the top.
And for that we are going to go down to the anchor tag, ul.MenuBarVertical a. Typically, the background image is applied to the anchor tag. So I find bringing in background images is easiest through the CSS Rule dialog box. So I am going to go up here and I am going to go ahead and just clear the default color there, so we don't have that background color. And instead we will browse for an image. And you want to make sure that you're in the proper folder, which would be 02_04 in the _images subfolder and navigate down your list until you see nav_bg.gif.
We want to make sure that this doesn't repeat, so I will choose no-repeat, and we also want to position this so that it's at the left and top. Now, this background image is actually part of a sprite. I'll click OK. So now we can see our background image is coming in, but the text is obviously overlapping. So we can adjust that by changing the padding. So I'll go over to the padding rule here and change it to .25 ems for the top, .75 em for the right, .5 em for bottom, and 1.25 em for the left.
When I press Tab, you can see that all of them line up. Now that we have our background image on the primary items, if I move over to the subnavigation, you can see I still have some work there. Let's go ahead and address that. Now in this case, I am actually going to have to add a rule. There is no anchor tag for subnavigation addressed here just by itself, so I'm going to right-click on my CSS rule that we are just working on, and choose Go to Code. I like to group these CSS Rules together wherever I can, and in this case it's ul.MenuBarVertical ul a, then we will do an open curly brace and a close curly brace. And we want to get rid of the background image, make sure that doesn't appear, so I'll type in background-image: URL(none).
Now when I go over and click Refresh, my new tag appears in the CSS Styles panel and I can add a background color property and sample my tan background. So there's actually about three different places where you have to put that tan background in to actually make it work right. Okay, we are getting closer. Let's go ahead and close that off. Now it's time to get rid of this right arrow. You'll find that the rule for it is actually in two places, and it's located below this group of hover rules that you see here.
The first one is ul.MenuBarVertical a. MenuBarItemsSubmenu, and we also want to change the one right below it. You will notice that they both have this background image property, so let's see if we can get rid of the background image properties in all of these. I am going to opt to disable these background image properties one at a time, and let's go up and do that in the previous menu as well. Okay, so that has brought us a step closer.
As you can see, there's still some issues where we have the default border bottom appearing here and we want to get rid of that, and those are located in the hover state, and the rules are found just above the two we were working with. Choose the first one, which is ul.MenuBarVertical a:hover, ul.MenuBarVertical a focus, and with that chosen, we want to disable the background color, and we actually want to change the color of it, so that it uses the orange in the logo. So I will click the color icon and then go over and sample the orange.
Now we need to add a couple of other properties. I mentioned that it still has that border bottom. So let's get rid of that by putting in a border-bottom, and then entering in the value of none, pressing Tab. And the final thing we need to do here is move the sprite over, and we do that by changing the background position. So I'll enter in background-position, and change that to a value of -272 pixels on the left and 0 from top and bottom.
So now when we hover over it, you can see that the background is changing, but we are still losing the other image, and that can be changed by addressing the second rule that has the background color of the dark blue. Again, we will go ahead and disable that, and let's change this color to orange. You have to do the same thing to the two rules. So now when we go over them, you can see that all of our hover colors are correct, and when we go over the item with the subnavigation, we also have exactly what we are looking for, which is the orange color coming up and no background graphics.
So all of these style techniques that we've applied to the vertical menu can also be applied to the horizontal one as well to create just the type of menu that you are looking for.
There are currently no FAQs about Site Navigation with CSS in Dreamweaver.
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.