The SpryMenuBarHorizontal.css and SpryMenuBarVertical.css files provide the default styling for the Menu Bar widget. You can, however, customize the widget by changing the appropriate CSS rule. The CSS rules in the SpryMenuBarHorizontal.css and SpryMenuBarVertical.css files use the same class names as the related elements in the menu bar’s HTML code, so it’s easy for you to know which CSS rules correspond to the different sections of the Menu Bar widget. Additionally, the SpryMenuBarHorizontal.css and SpryMenuBarVertical.css files contain class names for widget behaviors (for example, hovering and clicking behaviors).
The horizontal or vertical styling sheet for the widget should already be a included in your website before you start customizing. For more information, see Prepare your files.
You can style an Menu Bar widget by setting properties for the entire Menu Bar widget container, or by setting properties for the components of the widget individually.
You can replace style-related class names in the CSS files and HTML code with class names of your own. Doing so does not affect the functionality of the widget.
The SpryMenuBarHorizontal.css and SpryMenuBarVertical.css files have extensive comments, explaining the code and the purpose for certain rules. For further information, see the comments in the file.
The CSS code attached to the a tag contains the information for text styling. Several relevant text-styling class values that pertain to different menu states are attached to the a tag.
Style to change |
CSS rule for vertical or horizontal menu bar |
Relevant properties and default values |
---|---|---|
Default text |
ul.MenuBarVertical a, ul.MenuBarHorizontal a |
color: #333; text-decoration: none; |
Text color when mouse pointer moves over it |
ul.MenuBarVertical a:hover, ul.MenuBarHorizontal a:hover |
color: #FFF; |
Text color when in focus |
ul.MenuBarVertical a:focus, ul.MenuBarHorizontal a:focus |
color: #FFF; |
Menu Bar item color when mouse pointer moves over it |
ul.MenuBarVertical a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemHover |
color: #FFF; |
Submenu item color when mouse pointer moves over it |
ul.MenuBarVertical a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover |
color: #FFF; |
The CSS rule attached to the a tag contains the information for a menu item’s background color. Several relevant background color class values are attached to the a tag that pertain to different menu states.
Color to change |
CSS rule for vertical or horizontal menu bar |
Relevant properties and default values |
---|---|---|
Default background |
ul.MenuBarVertical a, ul.MenuBarHorizontal a |
background-color: #EEE; |
Background color when mouse pointer moves over it |
ul.MenuBarVertical a:hover, ul.MenuBarHorizontal a:hover |
background-color: #33C; |
Background color when in focus |
ul.MenuBarVertical a:focus, ul.MenuBarHorizontal a:focus |
background-color: #33C; |
Menu Bar item color when mouse pointer moves over it |
ul.MenuBarVertical a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemHover |
background-color: #33C; |
Submenu item color when mouse pointer moves over it |
ul.MenuBarVertical a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover |
background-color: #33C; |
To change the dimension of menu items by changing the width properties of the menu item’s li and ul tags.
The position of Spry Menu Bar submenus is controlled by the margin property on submenu ul tags.
By default, the Menu Bar widget, as well as its menu and submenu items, are all aligned left on the page. You can center the Menu Bar widget itself by adding some code to the page on which the Menu Bar widget appears.
The example demonstrates centering a horizontal Menu Bar widget, but you can center a vertical Menu Bar widget within its container if you are using one.
By default, the Menu Bar widget, as well as its menu and submenu items, are all aligned left on the page. You can center the menu items inside the menu bar by adding some code to the page on which the Menu Bar widget appears. This task does not center the submenu items.
The example demonstrates centering a horizontal menu bar’s menu items, but you can also apply this to a vertical Menu Bar widget if you are using one.
By default, the horizontal Menu Bar widget, as well as its menu and submenu items, are all aligned left on the page. You can center all of the menu items inside the menu bar by adding some code to the page on which the Menu Bar widget appears. This task centers all menu items and submenu items.
The example demonstrates centering all menu items in a horizontal menu bar, but you can also center all items in a vertical Menu Bar widget if you are using one