Changing the Font and Width of a Horizontal Spry Menu Bar

The following instructions split the customization process for a horizontal menu bar into easy steps. There are separate instructions for a vertical menu bar.

Changing the menu bar fonts

If your main style sheet defines the fonts to be used on the page, they will be automatically inherited by the menu bar. However, you might want to use different fonts for the menu. All changes affecting font-family, font-weight, and font-size should be made in the first style rule, ul.MenuBarHorizontal. This rule affects everything in the menu bar.

  1. Open the style sheet you renamed and attached to the page in the previous section.

  2. There are two style rules that set font-size to 100%: ul.MenuBarHorizontal (the first rule in the style sheet) and ul.MenuBarHorizontal li, which appears slightly further down.

    If you want to use a percentage font size or ems, change only the first rule (ul.MenuBarHorizontal). Changing the value of the font-size property in the rule further down (ul.MenuBarHorizontal li) will shrink the text in the submenus, making it progressively smaller with each new level.

    If you want to use pixels for the font size, make the change in the second of these two rules (ul.MenuBarHorizontal li).

    For the purposes of this tutorial, change font-size in ul.MenuBarHorizontal to 90%.

  3. To change the fonts used in the menu, add the font-family property to the ul.MenuBarHorizontal style rule. I used Tahoma, Geneva, sans-serif.

  4. The text in the menu bar looks better in a bold font, so add font-weight: bold; to the ul.MenuBarHorizontal style rule.

That completes the main changes to the fonts. The amended style rule should now look like this:

ul.MenuBarHorizontal { margin: 0; padding: 0; list-style-type: none; font-size: 90%; cursor: default; width: auto; font-family:Tahoma, Geneva, sans-serif; font-weight:bold; }

Adjusting the menu item widths

The width of each menu item is controlled in three places. The first one (ul.MenuBarHorizontal li) controls the top-level menu items. The other two (ul.MenuBarHorizontal ul and ul.MenuBarHorizontal ul li) control the width of the items in the submenus. By default, the top-level items are 8em, and the submenus 8.2em. For the purposes of this tutorial, I'm going to make them all 160px wide.

  1. Locate the ul.MenuBarHorizontal li style rule (it's the third from the top) to change the width of the top-level items. Change width: 8em; to width: 160px;. Make sure there is no space between the number and px.

  2. Now change the width of the submenu items. Locate the ul.MenuBarHorizontal ul style rule, and change width: 8.2em; to width: 160px;.

  3. Make the same change in the ul.MenuBarHorizontal ul li style rule (it's two further down from ul.MenuBarHorizontal ul).

All that remains for the basic customization of the menu bar is to change the colours.

Back | Next

Quick links to other pages of this tutorial

Planning your Spry Menu Bar

Inserting a Spry Menu Bar and copying the style sheet

Changing the font and width of a horizontal Spry Menu Bar

Changing the colours of a horizontal Spry Menu Bar

Changing the font and width of a vertical Spry Menu Bar

Changing the colours of a vertical Spry Menu Bar

Books by David Powers

Dreamweaver CS5 with PHPGetting StartED with CSSEssential Guide to Dreamweaver CS4PHP Object Oriented SolutionsPHP Solutions