Menu classes are used to give a different design scheme to selected menus and menu items.
Classes are defined in
name-indexed arrays, the names of which correspond to the class name
of the <ul>
and <li>
items you want them to apply to. So for example, these arrays:
um.menuClasses['orangeMenu']
um.itemClasses['orangeMenuItem']
PHP
$um['menuClasses']['orangeMenu']
$um['itemClasses']['orangeMenuItem']
go with this HTML:
<ul class="orangeMenu">
<li class="orangeMenuItem">
...
</li>
</ul>
Both menu and menu-item classes cascade, so classes will apply to all children of the same element. The class arrays are designed to do this - to be used for multiple menus or items - but if you only want to tweak the style of individual elements you can do so by styling them from external CSS.
A menu or menu-item which has one of these custom
class
names cannot have
any other class
name: a value
such as "foobar orangeMenuItem"
will not work.
Classes which apply to menus.
//classes which apply to menus
um.menuClasses['orangeMenu'] = [
'#fdcb95 #a97742 #a97742 #fdcb95', // border colors ["color"|"#hex"|"rgb()"]
'solid', // border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'8em', // width ["em"|"ex"|"px"]
'#fec', // background ["color"|"#hex"|"rgb()"|"image.gif"]
'', // additional menu CSS
'orangeshadow.png', // shadow background ["color"|"#hex"|"rgb()"|"image.gif"|"none"]
'2px', // shadow offset (+-)["em"|"ex"|"px"|"%"|"0"]
'', // additional shadow layer CSS
];
PHP
//classes which apply to menus
$um['menuClasses']['orangeMenu'] = array(
'#fdcb95 #a97742 #a97742 #fdcb95', // border colors ["color"|"#hex"|"rgb()"]
'solid', // border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'8em', // width ["em"|"ex"|"px"]
'#fec', // background ["color"|"#hex"|"rgb()"|"image.gif"]
'', // additional menu CSS
'orangeshadow.png', // shadow background ["color"|"#hex"|"rgb()"|"image.gif"|"none"]
'2px', // shadow offset (+-)["em"|"ex"|"px"|"%"|"0"]
'', // additional shadow layer CSS
);
Classes which apply to menu items.
//classes which apply to menu items
um.itemClasses['orangeMenuItem'] = [
'#fec', // border colors ["color"|"#hex"|"rgb()"]
'solid', // border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#edbb85', // hover/focus border colors ["color"|"#hex"|"rgb()"]
'solid', // hover/focus border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#fec', // visited border colors ["color"|"#hex"|"rgb()"]
'solid', // visited border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#fec', // background ["color"|"#hex"|"rgb()"|"image.gif"]
'#f8fbd0', // hover/focus background ["color"|"#hex"|"rgb()"|"image.gif"]
'#fec', // visited background ["color"|"#hex"|"rgb()"|"image.gif"]
'70%', // font size ["em"|"ex"|"%"|"px"|"pt"|"absolute-size"|"relative-size"]
'tahoma,sans-serif', // font family ["font1,font2,font3"]
'normal', // font weight ["normal"|"bold"|"bolder"|"lighter|"100" to "900"]
'none', // text decoration ["none"|"underline"|"overline"|"line-through"]
'left', // text-align ["left"|"right"|"center"]
'#803090', // color ["color"|"#hex"|"rgb()"]
'#5656bd', // hover/focus color ["color"|"#hex"|"rgb()"]
'#803090', // visited color ["color"|"#hex"|"rgb()"]
'normal', // font-style ["normal"|"italic"|"oblique"]
'normal', // hover/focus font-style ["normal"|"italic"|"oblique"]
'normal', // visited font-style ["normal"|"italic"|"oblique"]
'padding-left:5px;', // additional link CSS
'padding-left:5px;', // additional hover/focus CSS
'', // additional visited CSS
'right-purple.gif', // submenu indicator character/image ["text"|"image.gif"|"none"]
'right-blue.gif', // submenu indicator rollover image ["image.gif"|"none"]
'..', // alt text of indicator image ["text"]
];
PHP
//classes which apply to menu items
$um['itemClasses']['orangeMenuItem'] = array(
'#fec', // border colors ["color"|"#hex"|"rgb()"]
'solid', // border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#edbb85', // hover/focus border colors ["color"|"#hex"|"rgb()"]
'solid', // hover/focus border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#fec', // visited border colors ["color"|"#hex"|"rgb()"]
'solid', // visited border styles ["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
'#fec', // background ["color"|"#hex"|"rgb()"|"image.gif"]
'#f8fbd0', // hover/focus background ["color"|"#hex"|"rgb()"|"image.gif"]
'#fec', // visited background ["color"|"#hex"|"rgb()"|"image.gif"]
'70%', // font size ["em"|"ex"|"%"|"px"|"pt"|"absolute-size"|"relative-size"]
'tahoma,sans-serif', // font family ["font1,font2,font3"]
'normal', // font weight ["normal"|"bold"|"bolder"|"lighter|"100" to "900"]
'none', // text decoration ["none"|"underline"|"overline"|"line-through"]
'left', // text-align ["left"|"right"|"center"]
'#803090', // color ["color"|"#hex"|"rgb()"]
'#5656bd', // hover/focus color ["color"|"#hex"|"rgb()"]
'#803090', // visited color ["color"|"#hex"|"rgb()"]
'normal', // font-style ["normal"|"italic"|"oblique"]
'normal', // hover/focus font-style ["normal"|"italic"|"oblique"]
'normal', // visited font-style ["normal"|"italic"|"oblique"]
'padding-left:5px;', // additional link CSS
'padding-left:5px;', // additional hover/focus CSS
'', // additional visited CSS
'right-purple.gif', // submenu indicator character/image ["text"|"image.gif"|"none"]
'right-blue.gif', // submenu indicator rollover image ["image.gif"|"none"]
'..', // alt text of indicator image ["text"]
);
["color"|"#hex"|"rgb()"]
["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
"none"
then please be aware that the border size is
part of the menu positioning calculations, and if the border-style is "none"
there'll be a value but no rendered border, so you'll get a
position discrepancy equal to the border size.
["color"|"#hex"|"rgb()"]
["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
["color"|"#hex"|"rgb()"]
["solid"|"double"|"dotted"|"dashed"|"groove"|"ridge"|"inset"|"outset"]
["color"|"#hex"|"rgb()"|"image.gif"]
"transparent"
.
["color"|"#hex"|"rgb()"|"image.gif"]
["color"|"#hex"|"rgb()"|"image.gif"]
["em"|"ex"|"%"|"px"|"pt"|"absolute-size"|"relative-size"]
Specify the navbar font size using any valid CSS value.
"absolute-size" means a value such as "small"
or "large"
;
"relative-size" means "smaller"
or "larger"
.
I strongly recommend
you DO NOT use "px"
or "pt"
, because they create
unscaleable text in Win/IE.
And although you can use
"ex"
units, I wouldn't recommend them either, because browsers have
very different ideas about how big they are.
I think the best units to use are "em"
or "%"
.
["font1,font2,font3"]
"serif"
, "sans-serif"
, "cursive"
,
"fantasy"
or "monospace"
.
["normal"|"bold"|"bolder"|"lighter|"100" to "900"]
["none"|"underline"|"overline"|"line-through"]
Specify the text-decoration of menu links using any valid CSS value.
There is a text-decoration value "blink", but you shouldn't use it - the Web Content Accessibility Guidelines specifically say to avoid causing content to blink, because it may trigger a seizure in a person who has photosensitive epilepsy.
["left"|"right"|"center"]
["color"|"#hex"|"rgb()"]
["color"|"#hex"|"rgb()"]
["color"|"#hex"|"rgb()"]
["normal"|"italic"|"oblique"]
["normal"|"italic"|"oblique"]
["normal"|"italic"|"oblique"]
You can use this space to pass any additional CSS to the default state of menu links - for example, if you use image backgrounds you should define a redundent background-color for browsers that don't display images. In theory there are no limitations, but in practise you should be very careful, particularly with properties which are already defined elsewhere, such as position, margins or padding.
Ultimately nothing you do here is guaranteed to work - it's up to you to do thorough testing; some rules may need !important to be stable or have sufficient specificity.
Whatever you define here automatically applies to the visited state as well.
["text"|"image.gif"|"none"]
Specify a textual character or image which is used
to indicate a nested menu, or "none"
if you don't
want an indicator. If you use an
image you must also provide
alt text.
To help you choose suitable alt text or characters,
please read
The semantics of menu indicators.
You cannot use entities such as
…
or …
because the characters
are created using createTextNode
, which cannot create entities
(there is a createEntityReference
method, but at the time of writing
no browser implements it).
You can use
unicode characters [PDF] in the form of escaped
hex values, for example
"\u21d2"
is a right-pointing arrow. However these
are not particularly well supported cross-browser, and might be
problematic in browser-based screenreaders -
for example, Home Page Reader
sees "?" for an unknown character, and says question mark
.
Submenu indicators are not supported in Mac/IE5; image indicators are not supported in Mozilla Gecko browsers 0.9.4 (Netscape 6.2) or earlier.
["image.gif"|"none"]
If you're using an image indicator you can also specify a rollover image.
If you're using a textual indicator you cannot specify a separate rollover as such - the characters will do whatever CSS changes they inherit from their parent link.
["text"]
Item classes are designed to cascade, so that you only need
a minimum of hard-coded class
attributes: applying the
styles to <a>
descendents of
<li>
means that all
child links inherit the same styling.
This fits well with menu-item styling, because I think it's likely that you'd want an entire branch of menus to have the same appearance. But for the navbar it's possibly more likely that you'd want individual items to have their own styling, and for those styles not to cascade to child menus.
Internet Explorer 5 and 6 don't support child selectors, so navbar item classes would either:
<a>
instead
The latter is possible, but I decided against it - partly because it
seemed more smenatically fitting to have the class
name applied to <li>
,
but mostly because it would take a lot more actual
CSS
to generate the styling automatically than it would if you simply
specified the styles yourself,
from an external stylesheet. Automatic CSS generation
has to allow for theoretical possibilities that may not be present,
which takes more redundent code.
So, to reduce the overall size of the CSS generating script, and the
size of the resultant stylesheet, there are no ad-hoc navbar items classes -
if you want to specify individual styles you can do so by applying
a class
or id
to the link
in question, and styling it yourself.
This is very easy to do - since the underlying structure is just HTML, it's essentially no different than styling anything else on your page. Please read Styling the navbar externally for more details and examples.
UDM 4 is valid XHTML, and in our judgement, meets the criteria for WAI Triple-A conformance.