- Blue Lobster Art and Design - http://blulob.com -
Make a Multi-Level CSS Dropdown Menu in Dreamweaver CS4
Posted By Dawn Pedersen On 05/29/2009 @ 11:43 pm In CSS,Dreamweaver,Tutorials | 79 Comments

Menu Preview
For this tutorial, we’ll be making a horizontal navigation bar for a zoo. It will have dropdowns and a couple of items will have flyouts to the right. We’ll simplify it the navigation by pretending our zoo has only four animals. I guess we can’t expect too many paid admissions. Luckily, after you’ve completed this tutorial you should be able to adapt this technique for any site.

Kookaburra
It will help to create an outline of how we want our navigation organized. This can be done on the computer, but I often find myself sketching things up on Post-It notes or sheets of scratch paper. Here’s my sketch:

Sketch of Navigation Organization
An alternate outline would look like this:
Both of these outlines together will help us visualize how our navigation will be built. Let’s go!
Our navigation bar has two components: the HTML on the web page, and the CSS styling which will be in an external CSS style sheet that can control every page on our site. We’ll start with the basic content in HTML without any styling. Take a look at that second outline above. We need to recreate that in Dreamweaver. Remember to save your file frequently!

Create a new HTML page

Save As and Design button

Unordered List icon

First Level Navigation

Second-level navigation

Subnavigation for Visit Us

Subnavigation for Animals

Subnavigation for Birds

Subnavigation for Beasts

Add a link placeholder

Add link placeholders
All of our basic HTML scripting is done. Now we need to tell Dreamweaver what CSS classes and IDs to use in the HTML. And we need to set up all of our style rules in an external CSS file.
Next: Step Three: Start Building the CSS [8]
Our menu will belong to CSS class called dropdown. The CSS file will do different things with this dropdown class, depending on whether we are inside the main list, or some secondary or tertiary item. Here’s a quick run down of the components we will style (ul means unordered list and li means list item):
Let’s dive in with the first one!

New CSS Style

New CSS Rule box
| Category | Subcategory | Setting | Value |
|---|---|---|---|
| Background | Background color | #cccccc | |
| Box | Float | left | |
| Padding (CHECK same for all) | Top | 0 | |
| Margin (CHECK same for all) | Top | 0 | |
| List | List-style-type | none | |
| List-style-image | none | ||
| Positioning | Position | relative | |
| Z-index | 597 | ||

Apply the dropdown class to the main list

Menu with the dropdown class applied to it
| Category | Setting | Value |
|---|---|---|
| Type | Font-family | Georgia, "Times New Roman", Times, serif |
| Color | #4a53a2 | |
| Text-decoration | none |
Here’s the menu with the link (and visited link) styles we created:

Menu with new link styles
| Category | Setting | Value |
|---|---|---|
| Type | Font-family | Georgia, "Times New Roman", Times, serif |
| Color | #000000 | |
| Text-decoration | none |
To see the effect of the hover setting, save the menu.html file and press F12 to preview the file in a browser. If you get a dialog box asking you to save menu.html, say Yes. If you get a dialog box warning you that some pages have been modified but not saved, that means the new menu.css file; click Yes.
Here, I am hovering over the word Birds in the browser, which changes color to black.

Hover changes the text color to black
Next: Step Four: CSS Menu Magic [9]
Now we’ll begin popping that menu out to the right and building the dropdowns.
| Category | Subcategory | Setting | Value |
|---|---|---|---|
| Background | Background color | #cccccc | |
| Box | Width | 150px | |
| Padding (CHECK same for all) | Top | 0 | |
| Margin (CHECK same for all) | Top | 0 | |
| List | List-style-type | none | |
| List-style-image | none | ||
| Positioning | Position | absolute | |
| Visibilty | hidden | ||
| Width | 150px | ||
| Z-index | 598 | ||
| Placement | Top | 100% | |
| Left | 0 | ||
Make sure you put % for the Top placement, not px!
Here’s what the ul.dropdown ul style rule did to the second level items under Visit Us and Animals:
Now if you view the page in a browser, the menu has collapsed so that only the first level appears.

Collapsed menu
| Category | Subcategory | Setting | Value |
|---|---|---|---|
| Type | Line-height | 1.3em | |
| Block | Vertical-align | middle | |
| Box | Float | left | |
| Padding (UNCHECK same for all) | Top | 7px | |
| Right | 30px | ||
| Bottom | 7px | ||
| Left | 10px | ||
| Margin (CHECK same for all) | Top | 0 | |
| Border (UNCHECK same for all in all 3 columns) | Right | Style | solid |
| Width | 1 pixel | ||
| Color | #999999 | ||
| List | List-style-type | none | |
| List-style-image | none | ||
You will find that the menu is now horizontal when viewed in a browser; the Float: left did that. There is ample padding between the text and the edges of each button. There is also a dark gray separating line to the right of each button.

Horizontal first-level buttons

Funky Dreamweaver layout
| Category | Setting | Value |
|---|---|---|
| Background | Background-color | #eeeeee |
| Positioning | Position | relative |
| Z-index | 599 |
Check out the cool color change when you hover over a button in the browser.

Hovering over a button
| Category | Setting | Value |
|---|---|---|
| Positioning | Visibility | visible |

The subnagivation appears!
| Category | Subcategory | Setting | Value |
|---|---|---|---|
| Box | Float | none | |
| Border (CHECK same for all in all 3 columns) | Top | Style | none |

Borders removed
| Category | Subcategory | Setting | Value |
|---|---|---|---|
| Positioning | Placement | Top | 1px |
| Left | 99% |
Make sure you put % for the Left placement, not px!

Pop those birds and beasts out
Next: Customizing the Menu for Your Needs [10]
This menu is fine for a four-animal zoo if you happen to own one. Chances are you don’t, so you need to adapt this menu for your own needs. Here are some tips.
Content
Try to organize the navigational structure before coding, and get the HTML lists all squared away as in “Step Two: Build the HTML [11]” before you build the CSS. Because Dreamweaver doesn’t display complex menus quite right, you might need to go into the code directly to make changes to the HTML list later. Alternately, you can detach the CSS in order to edit the HTML more easily, then reattach it. This is a simpler solution if you are unfamiliar with HTML. (Get familiar! It’s totally worth it.)
To detach the CSS file from your HTML file:

Detach CSS file
To reattach the CSS file to your HTML file:
Incorporating the Menu into a Page
Chances are good too that you want this menu inside a page instead of by itself. Here are some loose instructions for that, if you already have a web page with an external CSS file attached to it. This code will work for a menu with any number of items up to three levels deep.

Select the entire ul.dropdown

View menu.css
Changing the Font or Colors
To change any individual CSS rule, you click on its name in the CSS Styles panel and click on the Edit Rule… icon at the bottom of the panel.

Edit Rule... icon
To change the font, click on ul.dropdown a:link and click the Edit Rule icon. Change the Font-family in the Type category and click OK. Do the same for ul.dropdown a:visited and ul.dropdown a:hover. You can edit the text color here too.
To change the background color, edit ul.dropdown: click on the color swatch for background-color in the Background category, and select a new color.
To change the background color for the hover state, edit ul.dropdown li:hover in a similar manner.
Adding a Background Image
You may notice that my own menu above behaves like the one we just designed, but it has a buttony look which is supplied by this background image (you may steal it).
![]()
Save your background image somewhere in your Web site folder. Here’s where the background image needs to be placed in our CSS code:
In each case, do the following:
Good luck! If you have any questions or feedback, I’d love to hear from you in the comments below.

Article printed from Blue Lobster Art and Design: http://blulob.com
URL to article: http://blulob.com/2009/05/29/multilevel-css-dropdown-menu-dreamweaver/
URLs in this post:
[1] Tweet: https://twitter.com/share
[2] Preview our menu here.: http://www.bluelobsterart.com/previews/menu.html
[3] Kookaburra: http://en.wikipedia.org/wiki/Kookaburra
[4] Hammerkop: http://en.wikipedia.org/wiki/Hammerkop
[5] Wolverine: http://en.wikipedia.org/wiki/Wolverine
[6] Wombat: http://en.wikipedia.org/wiki/Wombat
[7] Document Toolbar: http://bluelobsterart.com/2009/03/11/the-dreamweaver-cs4-workspace/
[8] Start Building the CSS: http://blulob.com/2009/05/29/multilevel-css-dropdown-menu-dreamweaver/2/
[9] CSS Menu Magic: http://blulob.com/2009/05/29/multilevel-css-dropdown-menu-dreamweaver/3/
[10] Customizing the Menu for Your Needs: http://blulob.com/2009/05/29/multilevel-css-dropdown-menu-dreamweaver/4/
[11] Step Two: Build the HTML: http://blulob.com/2009/05/29/multilevel-css-dropdown-menu-dreamweaver/
[12] Master Your Website Layout with these 6 CSS Properties: http://blulob.com/2009/06/03/6-ways-play-css-layers/
[13] 3-Column Web Page Using CSS Layers in Dreamweaver CS4: http://blulob.com/2009/03/10/create-a-3-column-web-page-using-css-layers/
[14] Evolution of a Web Design: http://blulob.com/2009/05/02/evolution-of-a-web-design/
[15] The Dreamweaver CS4 Workspace: http://blulob.com/2009/03/11/the-dreamweaver-cs4-workspace/
[16] The Hexadecimal Color Wheel: http://blulob.com/2009/03/15/the-hexadecimal-color-wheel/
Click here to print.
Copyright © 2009 Blue Lobster Art and Design. All rights reserved.