A basic working knowledge of Dreamweaver
and CSS is required.The Spry Menu Bar 2.0
widget uses nested unordered lists, so you
should befamiliar with how to create them
in Dreamweaver. For more information see
CreateBulleted and Numbered Lists in Dreamweaver Help.
spry_bayside.zip (141 KB)
So, the Dreamweaver engineering team rethought the whole way of working with Spry Menu Bars. The result is Spry Menu Bar 2.0, which uses a newer version of Spry designed specifically for creating user interfaces, SpryUI. They also introduced the Adobe Widget Browser, which makes it much easier to style Spry Menu Bar 2.0 and other widgets. Instead of spending time trying to figure out which CSS selector you need to edit, you do all the configuration through dialog boxes that describe the part of the widget they control. What's more, you get to see how the changes will look in a browser in real time. With just a little CSS knowledge, you can style a Spry Menu Bar 2.0 widget with confidence.
The Adobe Widget Browser is a separate AIR application that's closely integrated in Dreamweaver CS5. With a little extra work, you can also use the Widget Browser with earlier versions of Dreamweaver. However, the widgets need to be rendered in Dreamweaver using Live View, so using Dreamweaver CS3 or earlier is not recommended.
This tutorial shows how to install the Adobe Widget Browserand download the Spry Menu Bar 2.0 widget from the Adobe Exchange. You'll then style a horizontal fixed-width menu and insert it in the home page of a fictional events website called Bayside Pulse.
This article is divided into the following sections:
- Reviewing the task ahead
- Installing the Adobe Widget Browser
- Choosing widgets from the Adobe Exchange
- Configuring a Spry Menu Bar 2.0 widget
- Setting the layout and width of the menu bar
- Configuring the submenu layout
- Setting the text and background colors
- Preparing to add embossed borders to the menu items
- Setting up the site in Dreamweaver
- Deploying a Spry Menu Bar 2.0 widget in Dreamweaver
In order to make the most of this article, you need the following software and files:
Reviewing the task ahead
The sample files for this tutorial contain the home page of a fictional events website called Bayside Pulse (see Figure 1).
Figure 1. The starter Bayside Pulse home page lacks a navigation menu.
The design lacks a navigation menu to take visitors to other pages. For this project, you'll use Spry Menu Bar 2.0 and the Adobe Widget Browser, both of which you'll download and install. By default, a Spry Menu Bar 2.0 widget is in neutral shades of gray (see Figure 2), and it expands andcontracts depending on the size of the menu labels.
Figure 2. Before styling, a Spry Menu Bar 2.0 is in neutral gray.
The colors need to be updated, and the menu bar needs to be the same width as the site's banner heading, 960 pixels. By the time you have finished, you'll have created a navigation menu that blends with the rest of the page (see Figure 3).
Figure 3. The finished menu bar includes updated fonts, colors, and borders.
The finished page is in the completed folder of the sample files for this tutorial. Most of the menu items are dummy links, but the Home and Café Citrus menu items link to index.html and citrus.html, respectively.
Note: To select the colors for the menu, I visited http://kuler.adobe.com/, selected the option to create a theme from an image, and uploaded the bannerimage, bayside_pulse.jpg. Using kuler is a quick and easy way to get harmoniouscolor schemes.
The Adobe Widget Browser isn't installed by default, but it's closely integrated with Dreamweaver CS5. You can also use the Widget Browser with earlier versions of Dreamweaver, but without the same level of integration. The Widget Browser lets you preview widgets on the Adobe Exchange. The widgets are free. When you find one you like, you can download and customize it, saving your changes for automatic insertion in a Dreamweaver site. All you need is an Adobe ID to log into the Adobe Exchange and download them.
Although the Widget Browser is a separate application, the easiest way to access it is through Dreamweaver CS5. If you're using an earlier version of Dreamweaver, you need to download the Widget Browser from Adobe Labs, and install it separately. The following instructions apply only to Dreamweaver CS5.
- Make sure you're connected to the Internet, click the Extend Dreamweaver icon in the Application Bar, and choose Widget Browser (see Figure 4).
Figure 4. Access the Widget Browser inside Dreamweaver CS5.
On a Mac, if you can't see the Extend Dreamweaver icon, choose Window > Application Bar.
- If the Widget Browser is already installed, it should launch. Skip ahead to
Choosing widgets from the Adobe Exchange.
- If you see an alert telling you that the Widget Browser isn't installed, click OK. This launches your default browser and takes you to the Widget Browser's page on the Adobe website.
- Click the link to download the Widget Browser. At this stage, you might be prompted to log in with your Adobe ID. This is normally your email address. If you don't have an Adobe ID, click Create an Adobe Account. The registration process should take only a couple of minutes.
- On the download page, click Install Now if you have Flash Player installed. Otherwise,click the download link.
- When prompted to open or save the file, click Open.
- When asked to confirm if you want to install the application, click Install, and type your computer's administrator password if necessary.
- When the installation has completed, the Widget Browser should launch automatically. Click Accept to accept the license agreement.
The Widget Browser lets you inspect widgets before deciding whether to download them. In this section, you'll log into the Adobe Exchange, and select the Spry Menu Bar 2.0 widget.
- You need to be signed into the Adobe Exchange to preview and download widgets. Click Sign In at the top right of the Widget Browser, and sign in with your Adobe ID and password.
- The Widget Browser displays thumbnail images of the widgets, together with brief details, including the author's name and user ratings. Select Spry Menu Bar 2.0 (see Figure 5).
Figure 5. Preview widgets on the Adobe Exchange.
- The Widget Browser displays details of the Spry Menu Bar 2.0 widget,including compatible browsers and compatible products.Note: Only Dreamweaver CS5 is listed as a compatible product, but this refers to integration with the Widget Browser. You can use Spry Menu Bar 2.0 with earlier versions of Dreamweaver by copying and pastingthe code into your web pages manually.
- Click Preview at the top right of the Widget Browser to preview the Spry Menu Bar 2.0 widget (see Figure 6). It comes with three presets. You can see what each one looks like in Live View. You can also inspect the underlying code by clicking the Code tab.
Figure 6. Preview the Spry Menu Bar 2.0 widget in the Widget Browser.
- Click Add To My Widgets at the bottom right of the Widget Browser. This launches the Widget License screen.
- Click Accept to download the widget to your computer.Note: If you can't see the Accept button, resize the Widget Browser window to bring it into view. The license screen isn't resizable.
- When the widget has been downloaded, click Go To My Widgets.
Once you have downloaded a widget from the Adobe Exchange, you can configure it inside the Widget Browser. The available options depend on how the widget was packaged by the developer. Spry Menu Bar 2.0 has a large number of options, giving you considerable control over its appearance. The options are divided into the following categories:
- Binding & Behavior: Changes the menu ID and speed of operation.
- Fonts: Offers a choice of web-safe fonts. Also changes the font size and weight.
- Menu Bar Layout: Determines the orientation (horizontal orvertical) and alignment of the menu. This is also where you set the width ofthe menu and menu items.
- Submenu Layout: Controls the width of submenus.
- Colors: Sets the colors for all parts of the menu, except borders.
- Menu Bar Borders: Offers a fine level of control over borders on the menu bar and top-level menu items.
- Submenu Borders: Sets the borders on submenus and submenu items.
Once you have configured a widget, you can save the settings for use in other pages. You can also build new presets based on an existing one.
Follow these steps to begin with the first two sets of options:
- Select Spry Menu Bar 2.0 in the My Widgets screen of the Widget Browser. This opens a preview of the menu bar on your local computer. The screen is identical to the one you saw when you previewed the menu bar on the Adobe Exchange, but with the addition of a Configure button at the bottom left.
- Select Fixed Width Submenus in the WIDGET PRESETS section, and click the Configure button. This opens a screen where you can change the look and behavior of the menu to suit your own needs (see Figure 7).
Figure 7. The Widget Browser provides a simple editing environment for the menu.
The panels on the left of the Widget Browser slide up and down, giving access to all the menu's settings. Any changes you make are reflected immediately in Live View on the right.
The first panel, BINDING & BEHAVIOR, lets you change the menu's ID and timing of the flyout menus. The delays are expressed in milliseconds, so the submenus appear and disappear after a delay of 0.2 seconds by default. These default values are fine as they are, so no changes arenecessary.
- Since you're going to save the changes you make to the look of the menu, you need to give it a unique name. Type Horizontal 960 Fixed Width Submenus in the Name text box on the bottom right.
- Click FONTS to open the next panel.
- In the Menu Bar section use the following settings:
- Font Family: "Lucida Sans Unicode", "LucidaGrande", sans-serif
- Size: 18px
- Weight: Bold
- Style: Normal
- Use the same settings in the Submenu section, but set Size to 16px.
The changes are reflected immediately in Live View (see Figure 8).
Figure 8. The new fonts are displayed in Live View.
Note: If you want to take a break at any stage, click the Save Preset button at the bottom right of the Widget Browser. This saves your changes, and lists Horizontal 960 Fixed Width Submenus under MY PRESETS in the Preview screen of the Spry Menu Bar 2.0 widget. To resume editing, select your configuration from MY PRESETS and click Configure.
The MENU BAR LAYOUT panel lets you choose whether to use a horizontal or vertical layout. If you choose a vertical menu bar, the width is automatically determined by the width of the menu items, and the menu is always aligned left. For a horizontal menu bar, you have the following options:
- Full width: The menu expands to fill the width of its containing element.
- Fixed width: The menu can be either left aligned or centered.
- Shrinkwrapped: The width is determined by the total width of the menu items, and the menu bar can be aligned either left or right.
This panel represents probably the most difficult part of configuring a Spry Menu Bar 2.0 widget, because it requires not only an understanding of how widths are calculated in CSS, but also of how the menu items are styled. The menu bar and submenus follow the widespread convention of styling nested unordered lists. So, the HTML markup for each menu item is simply a link inside an
<li>element like this:
<span>tag like this:
<li class="MenuItemContainer"><a href="index.html" class="MenuItem MenuItemFirst" tabindex="0"><span class="MenuItemLabel">Home</span></a></li>
You can see the effect this has on the structure of the menu items by giving each part a distinctive background color to make it easy to identify (see Figure 9). The item label is the green section immediately surrounding the text. The yellow area represents the menu item, and the narrow blue stripes represent the left and right borders of the menu items.
Figure 9. Distinctive background colors in a Spry Menu Bar 2.0 menu highlight the text, menu item, and borders.
The addition of the
<span>tag gives you the flexibility to style the center section of each menu item independently, but it also complicates the calculations you need to make when determining the values to enter in the MENU BAR LAYOUT panel. According to the CSS Box Model, the width of an element applies only to its content. Padding and borders are added outside the content, so you need to subtract these values from the width of the menu items.
The complete menu bar in the Bayside Pulse website has five top-level items. The overall width needs to be the same as the banner image, in other words 960 pixels. Divided by 5, that gives an overall width of 192 pixels for each menu item. I'm going to add a
2pxborder all round each item, so that reduces the width of the content to 188 pixels. Calculating the appropriate amount of padding is more a question of trial and error, but 25 pixels on either side of the text looks about right. That reduces the width of the menu item to 138 pixels.
Performing this calculation is absolutely vital to the success of customizing a Spry Menu Bar 2.0 widget. Remember that padding and borders are added outside the width of the menu item.
With that calculation out of the way, you can now adjust the settings in the MENU BAR LAYOUT panel.
- Click MENU BAR LAYOUT in the Widget Browser to reveal the options.
- In the top section, use the following settings:
Note: If you hover your mouse pointer over any of the options, the Widget Browser displays a tooltip explaining what the option is for.
- Menu Bar Orientation: Horizontal
- Horizontal Menu Bar Positioning: Left Aligned Fixed Width
- Menu Bar Width: 960px
- In the Item Width section, use the following settings:
- Item Label Width Type: Fixed Width
- Item Label Width: 138px
- Text Alignment: Center
- The next two sections set the padding for the menu item and item label. By default, each menu item has 39 pixels of horizontal padding on either side. The left padding is assigned to the item label. However, the right padding is split between the item label and the item. This is to leave sufficient room on either side of the submenu arrows.Since the design for the Bayside Pulse menu calls for 25 pixels of padding on the left and right, you need to split this value between the item and item label on the right.
- In the Item Padding section, change the value in the Right text box from 24 to 10. Combined with the
15pxdefault value for the item label, this adds up to
- Leave the other settings in the Item Padding section at their default value of
- In the Item Label Padding section, change the value in the Left text box from 39 to 25. Leave the other settings in the Item Label Padding section at their default values.
In the Widget Browser Live View, the menu is now beginning to take shape (see Figure 10). You might need to resize the Widget Browser to view the full width of the menu.
Figure 10. The menu is now a fixed width with equally sized top-level items.
The submenus are styled in the same way as the top-level menu items. In other words, a
<span>tag is added programmatically around the text, creating an item label within each submenu item. As with the top-level items, the padding on the right is split between the submenu item and the item label to leave space on either side of the submenu arrows. Although the SUBMENU LAYOUT panel has many options, it's relatively easy to configure once you understand the difference between item and item label.
- Click SUBMENU LAYOUT to reveal the next set of options.
- The first section allows you to offset the first level of submenus from the top-level items. Leave First Level Submenu Indent at its default value of
- The First Level Min-Width option controls the minimum width of submenu items. Its value depends on the first item in the Item Width section. If you choose Auto – Fit To Text, you should set First Level Min-Width to
100%. If you choose Fixed Width, it should be set to
0%.The Bayside Pulse design uses fixed-width submenus, so leave First Level Min-Width at the default value of
- In the Item Width section, set Item Label Width Type to Fixed Width.Setting the value for Item Label Width involves a calculation similar to the one you made for the top-level items. The Bayside Pulse design calls for the submenu items to be the same width as the top-level items—
192px. You need to deduct the amount of padding and borders from this figure. The default padding and borders are fine, so it's just a question of adding them up.
Adding these values together comes to 21 pixels. Deduct that value from the overall width of the submenu items (192-21=171) to get the value for Item Label Width.
- In the Item Padding section, Right is
2pxand Left is
- In the Item Label Padding section, Right is
12pxand Left is
- The borders are set in the SUBMENU BORDERS panel, and are just
1pxon each side, making a total width of
- In the Item Padding section, Right is
- Change Item Label Width from the default
- Leave all other settings at their default values.
- Test your settings by moving your mouse pointer over one of the top-level items with a submenu. The flyout submenus should be the same width as the top-level menu items (see Figure 11). Don't worry about a minor difference in the border alignment with the top level. That will be fixed when the top-level borders have been set.
Figure 11. The submenus are now the same width as the top-level items.
The COLORS panel controls the text and background colors of the top-level menu items and the submenus. Because the Spry Menu Bar 2.0 widget adds a
<span>around the text in both the top-level items and the submenu items, you have the option to apply a different background color to the item labels. For the Bayside Pulse menu, the background color of the labels will be inherited from the menu bar.
- Click COLORS to reveal the options for setting the background and text colors.The first option in the Menu Bar Text and Background section sets the background color for the whole menu bar. As long as you set the background colors of the items and labels to transparent, the top level items will inherit this color.
- Click the color box alongside Menu Bar Background, and type B0C9D9 in the text box at the top of the color swatch panel (see Figure 12).
Figure 12. Select a color using hexadecimal numbers without a leading hash symbol.
Note: The color picker in the Widget Browser automatically adds the hash symbol (#) to the code it generates. Do not add it here. Hexadecimal values consist of the numbers 0–9 and the letters A–F (case-insensitive) only. So, the second character in B0C9D9 is a zero, not the letter O.
- Click the color box alongside Item Background, and select the white color swatch with a red diagonal stripe at the top left of the color picker to set the value to transparent (see Figure 13).
Figure 13. Set the background color to transparent.
- Also set Label Background to transparent. Live View now displays the top-level menu items with a pale blue background (see Figure 14).
Figure 14. The menu items have inherited the background color from the menu bar.
- Leave Text at the default, black.
- Set Item Background Hover to 677E8C.
- Set Label Background Hover to transparent.
- Set Text Hover to white (FFFFFF).
- In the Submenu Text and Background section, use the following settings:
- Submenu Background: transparent
- Item Background: 677E8C
- Label Background: transparent
- Text: FFFFFF (white)
- Item Background Hover: B0C9D9
- Label Background Hover: transparent
- Text Hover: 000000 (black)
- Test the submenus in the Widget Browser's Live View (see Figure 15).
Figure 15. The menu bar now has new text and background colors.
The MENU BAR BORDERS panel has options to add a border to the whole menu bar and to the individual top-level menu items. The border widths must be the same on all sides, but you can control the color and style of each side separately. The options for the menu items give you considerable control. You can use a different color when the mouse pointer is hovering over an item, and you can apply different border styles to the first and last items.
For the Bayside Pulse site, the menu item borders will create the illusion of embossed buttons by using a lighter color for the top and left, and a darker color for the right and bottom. The light and dark colors will be reversed when the mouse pointer is hovering over a menu item, giving the impression of an inverse emboss.
Unless you have a keen sense of color, getting the light and dark shades right for the borders is difficult without a little help from a graphics program, such as Fireworks CS5. If you don't have a suitable graphics program handy, you can just read these instructions and use the colors in the next section. But a program such as Fireworks CS5 is indispensible for creating graphics for your websites, so I encourage you to download the trial version and follow along.
- Launch Fireworks CS5, and create a new Fireworks Document by choosing File > New or by clicking Fireworks Document (PNG) in the Create New section of the welcome screen. The canvas size needs to be big enough to draw a rectangle similar in size to one of the menu items in your Spry Menu Bar 2.0 widget.
- In the Colors section of the Tools panel, set the Fill Color to #B0C9D9, the same color as used for the main menu items in the Spry Menu Bar. Set the Stroke Color to transparent (select the white box with a diagonal red stripe).
- Select the Rectangle tool in the Vector section of the Tools panel, and draw a rectangle on the canvas. It should be filled with the same color as the top-level items in the Spry Menu Bar.
- With the rectangle still selected, click the plus (+) button next to Filters in the Properties panel, and select Bevel and Emboss > Inner Bevel (see Figure 16).
Figure 16. Apply a bevel to the rectangle.
- In the panel that opens, set the options in the pop-up menus to Flat and Raised, leave the other options at their default values, and click away from the panel. The rectangle has a bevel that makes it look like a raised button.
- Open the Info panel (Window > Info), and select the Pointer tool.
- Move the Pointer tool over the top edge of the bevel, and read the color from the RGB labels in the Info panel (see Figure 17). Write down the value as a hexadecimal color value: CDDCE7.
Figure 17. Use Fireworks to get the border colors for the menu items.
- Repeat the previous step with the bottom edge of the bevel. Note down the value: 5C6A72.
- Select the rectangle, and change the Fill Color to #677E8C.
- In the Properties panel, click the Inner Bevel filter to edit its settings. Change the value of the pop-up menu at the bottom from Raised to Inset, and click away from the panel. The rectangle now looks as though it's sunken into the canvas.
- Repeat steps 7 and 8, making note of the new colors: 697278 and B8C4CA.
- Close Fireworks without saving the file.
Note: You might get slightly different color values when using this technique. The exact values are unimportant, as long as they harmonize with the main color.
After selecting the border colors, all that remains is to apply them to the Spry Menu Bar 2.0 widget.
- In the Widget Browser, click MENU BAR BORDERS to reveal the options.
- By default, the menu bar has no border. The Width text box is set to
0pxand the Style for each side is set to None. These settings are fine.
- At the top of the Items section, change the value in the Width text box to 2px. This sets the border width for each side.There are separate sections for the top, right, bottom, and left borders. Each section has five options:
As you can see, you have precise control over each border. If you want only a thin vertical line between menu items, you can set the border style on all sides except the left to None, and suppress the left border on the first item.For this design, you want the same style on all borders, but the colors need to be different to produce the embossed effect.
- Color: Sets the normal border color for the selected side
- Hover Color: Sets the side's border color when the mouse pointer is hovering over the menu item.
- Style: Sets the side's border style on all items.
- First Item Style: Overrides the border style on the first menu item.
- Last Item Style: Overrides the border style on the last menu item.
- In the Top and Left sections, use the following settings:
In the Right and Bottom sections, use the following settings:
- Color: CDDCE7
- Hover Color: 697278
- Style, First Item Style, Last Item Style: Solid
- Color: 5C6A72
- Hover Color: B8C4CA
- Style, First Item Style, Last Item Style: Solid
- Test the menu bar in the Widget Browser's Live View (see Figure 18). Don't worry about the section on the right not looking like the other menu items. As soon as you create a new menu item in Dreamweaver, it will be styled like the others.
Figure 18. The menu bar now has borders.
Note: The final configuration panel (SUBMENU BORDERS) for the Spry Menu Bar 2.0 widget styles the submenu borders. By default, the submenu items have a one-pixel light gray border. The border happens to fit quite well with this color scheme, so there's no need to change the settings. However, if you need to change them for a different menu, the principles are exactly the same as for the main menu item borders.
- Click Save Preset at the bottom right of the Widget Browser to save the newly configured menu bar, which is now listed in MY PRESETS in the Spry Menu Bar 2.0 widget's Preview screen.
Because the Widget Browser is directly integrated in Dreamweaver CS5, you can insert a Spry Menu Bar 2.0 widget (or any other widget) with just a few clicks. If you're using Dreamweaver CS4, you need to copy and paste the code manually.
Whichever version you're using, you first need to set up the Bayside Pulse site for this tutorial.
All the necessary files are in the sample file, spry_bayside.zip.
- Extract the files in spry_bayside.zip to a convenient location on your computer. When extracted, you should have a folder named spry_bayside that contains two web pages, index.html and citrus.html, plus three other folders named completed, images, and styles.
- Define a Dreamweaver site named Spry Bayside, setting the spry_bayside folder as the site root (see Figure 19).
Figure 19. The structure of the Spry Bayside site is shown in the Files panel.
- Open index.html in the completed folder. In Design view, the menu bar is displayed as a series of nested unordered lists. Activate Live View or preview the page in a browser to see the menu bar rendered correctly. Most menu items are dummy links, but Café Citrus in the Eating Out > Quick Bites submenu links to citrus.html, and the Home menu item links back to index.html. To follow a link in Live View, you'll need to hold down the Ctrl key (Windows) or Cmd key (Mac OS X) while clicking it.
- Close index.html after you have tested the menu.
- Open the version of index.html in the Spry Bayside site root. It's the same page without the Spry Menu Bar 2.0 widget.The menu items in the horizontal version of a Spry Menu Bar 2.0 widget are floated, so you need to insert the menu bar in a
<div>that has a specified height. This preserves the vertical alignment of elements below the menu bar.
- Click the Insert Div Tag button in the Common category of the Insert panel/bar. Alternatively, choose Insert >Layout Objects > Div Tag. This opens the Insert Div Tag dialog box.
<div>needs to be inserted after the banner image, which is in a
header. In the Insert Div Tag dialog box, select After Tag from the Insert pop-up menu, and then select <div id="header"> from the pop-up menu on the right.
- Type nav in the ID text box (see Figure 20).
Figure 20. Insert a new for the menu bar.
- Click New CSS Rule. In the New CSS Rule dialog box that opens, Dreamweaver automatically selects the correct values for Selector Type and Selector Name.In the rule definition section make sure that bayside.css is selected. This is the file where the rule will be defined.
- Click OK to open the CSS Rule Definition dialog box.
- Select Box from the Category list on the left, and type 34 in the Height text box. Select px as the unit of measurement. This value has been calculated by adding the size of the text in the menu items (
18px), the top and bottom padding on the item labels (
6pxeach), and the top and bottom borders on the menu items (
- Click OK to close the CSS Rule Definition dialog box, and click OK again to close the New CSS Rule dialog box. You should now have a new
<div>with placeholder text between the banner image and the rest of the page content (see Figure 21).
Figure 21. The menu bar will go inside the new .
- Choose File > Save All Related Files (CS5 only) or File > Save All to save the changes to both index.html and bayside.css.
The page is now ready for the Spry Menu Bar 2.0 widget to be inserted. If you're using Dreamweaver CS5, follow the instructions in the next section. Otherwise, skip ahead to Using Earlier Versions Of Dreamweaver to insert the Spry Menu Bar 2.0 widget.
These instructions assume you have configured a Spry Menu Bar 2.0 widget as described in the preceding pages of this tutorial.
- Delete the placeholder text in the nav
<div>, and leave your insertion point inside the
- Click the Widget button in the Common category of the Insert panel/bar. Alternatively, select Insert > Widget.
- In the Widget dialog box, select Spry Menu Bar 2.0 (1.0) as the Widget and Horizontal 960 Fixed Width Submenus as the Preset (see Figure 22).
Figure 21. The menu bar will go inside the new .
- Click OK. Dreamweaver inserts the menu and all associated files. Unlike the original Spry Menu Bar, it's displayed in Design view as a series of unordered lists. This is normal.
- Save index.html. Dreamweaver presents you with the Copy Dependent Files alert (see Figure 23) informing you that the related files will be copied to a folder called Spry-UI-1.7. Click OK to save the files to the Spry Bayside site.
Figure 21. The menu bar will go inside the new .
You'll put the finishing touches to the Spry Menu Bar 2.0 widget in the final section of this tutorial. The next section describes how to transfer the menu bar from the Widget Browser to earlier versions of Dreamweaver. The instructions in the next section also apply if you want to move a Spry Menu Bar 2.0 widget manually to another page.
The Widget Browser is not integrated in earlier versions of Dreamweaver, so you need to export the files from the Widget Browser and transfer the code manually to index.html.
- Select Spry Menu Bar 2.0 in the Widget Browser, and select Horizontal 960 Fixed Width Submenus from the MY PRESETS section of the Preview screen.
- Click the Save Widget Files button at the bottom right of the Widget Browser. When prompted to choose a folder, navigate to the spry_bayside folder, which is the Spry Bayside site root. Click OK to save the files.
- When the Widget Browser has finished copying the files, it offers you the option to preview the menu bar. If you click Preview, it launches your default browser to display a page that contains only the menu bar. If you don't want to preview the menu bar, just click Close.
- Refresh the Files panel in Dreamweaver. You'll see a file named Spry Menu Bar 2.0_Horizontal 960 Fixed Width Submenus.html in the site root. There's also a new folder called Spry-UI-1.7, which contains all the necessary support files for the menu bar.
- Open the Spry Menu Bar 2.0_Horizontal 960 Fixed Width Submenus.html file in Code view. Inside the
<head>of the page is a
<link>tag, followed by six
<script>tags, and a
<style>block that's approximately 230 lines long. Copy all the code from the
<link>tag to the closing
</style>tag to your clipboard (around lines 6–246).
- Switch to index.html, also in Code view, and insert a blank line immediately before the closing
</head>tag (around line 7).
- Paste the code from your clipboard into the space you have just created.
- Return to Spry Menu Bar 2.0_Horizontal 960 Fixed Width Submenus.html. Copy all the code between (but not including) the opening and closing
<body>tags (around lines 250–304). This is the HTML for the menu bar (a series of unordered lists) plus a
<script>block that initializes the menu bar.
- Switch to index.html and locate the
nav <div>. It should be around line 253, and it looks like this:
<div id="nav">Content for id "nav" Goes Here</div>
- Delete the placeholder text between the
<div>tags, and paste the code for the menu bar in its place.
- Save index.html.
After inserting a Spry Menu Bar 2.0 widget into your first web page, you need to add the fifth top-level menu item, and edit the menu bar to link to different parts of the site. It's also a good idea to move the large
<style>block out of the
<head>of the page and merge the menu styles with your main style sheet—you'll do that in the next section.
In this tutorial, you'll simply add the fifth top-level menu item to the menu bar. You can follow a similar procedure to edit the other menu items and submenus.
- With index.html the active document in the Dreamweaver workspace, switch to Design view, and position the insertion point at the end of the final nested list item (Stock Car) in the menu bar.
- Press Enter/Return to add a new item to the list, and type Café Citrus.
- Select the text you have just typed, and create a link to citrus.html by typing the filename in the Link text box of the Property inspector in HTML mode.
- The new link is still part of the same second-level submenu as Stock Car. With the insertion point still in the Café Citrus text, click the Outdent button in the Property inspector twice (see Figure 24). This moves the new link to the top level of the series of nested lists that make up the menu bar.
Figure 21. The menu bar will go inside the new .
- Select the text "Home" in the first menu item, and create a link to index.html.
- Save index.html and activate Live View. The new menu item has been added to the menu bar (see Figure 25).
Figure 25. The fifth top-level menu item has been added.
- In Dreamweaver CS5, hold down the Ctrl key (Windows) or the Cmd key (Mac OS X) and click the Café Citrus menu item. You should be taken to citrus.html. (In older versions of Dreamweaver, you need to test this in a browser).You'll notice that citrus.html does not have the Spry Menu Bar 2.0 widget. You'll fix this in Adding the Spry Menu Bar 2.0 widget to other pages.
- Click the Live View button to return to Design view.
For the purposes of this tutorial, you can leave the other menu items unchanged; but in a site of your own, you'd edit the series of nested unordered lists to reflect the site's structure. Use the Indent button in the Property inspector to create submenus by nesting a list. Use the Outdent button to promote an item or list to a higher level.
Note: In a fixed-width design, the last menu item should not have a submenu more than one level deep. If you add a second-level submenu, it will be truncated by the page's container
With most widgets, including Spry Menu Bar 2.0, the Widget Browser attaches an external style sheet containing basic styles. It also embeds a
<style>block in the
<head>of the page containing rules that override the basic style sheet and style the widget according to the changes you made in the Widget Browser. It's a good practice to export these styles from the
<head>of the page to an external style sheet.
- Open the CSS Styles panel by clicking its tab, or by selecting Window > CSS Styles. On Windows, you can also use the keyboard shortcut, Shift+F11 (there is no Mac equivalent because of a conflict with Exposé).
- Click the All button at the top of the CSS Styles panel, and collapse the styles listed for bayside.css and SpryMenuBasic.css by clicking the tiny minus icon (triangle on a Mac) alongside the filenames. Expand the panel so you can see the remaining embedded styles (see Figure 26).
Figure 26. Look for the embedded styles created by the Widget Browser.
- Select the first style (
#MenuBar) and Shift-click the final one (
.SpryIsIE6 #MenuBar .SubMenu .SubMenu) to select all the embedded style rules.
- Right-click, and select Move CSS Rules.
- In the Move to External Style Sheet dialog box, select the option to move the rules to bayside.css, and click OK.
- Choose File > Save All Related Files (CS5) or File > Save All.
The styles created by the Widget Browser for Spry Menu Bar 2.0 are designed to override the basic styles in SpryMenuBasic.css regardless of which order you link the style sheets.
To add the menu bar to citrus.html, you need to copy and paste the link to SpryMenuBasic.css and the six
<script>tags from the
<head>of index.html into the
<head>of citrus.html. You also need to copy and paste the whole
Note: If you have any difficulty doing this, you can open the version of citrus.html in the completed folder of the sample files to see an example.
Performing these steps for every page in a site is obviously a tedious chore, so you should use a Dreamweaver template, library item, or server-side include to automate the process. When you use one of these options, any changes to the master file are automatically reflected in every page that uses the menu bar.
Where to go from here
You can use the Adobe Widget Browser to quickly style a Spry Menu Bar 2.0 widget through a series of configuration panels without delving into the complexities of the CSS style rules, many of which are applied programmatically. The large number of options gives you precise control over the look and behavior of the menu bar. With so many options, it can feel overwhelming to start with, but Live View in the Widget Browser lets you experiment with them in a nondestructive way.
To learn more about the UI widgets that are used in Spry Menu Bar 2.0, see Spry UI on Adobe Labs.
Here are some other resources that you may find helpful as you work with the Spry Menu Bar 2.0 widget: