Menu
Hi,
I am tasked with creating a top navigation bar similar to the one at:
[url]www.apple.com
I am now trying to learn JavaScript and CSS.
I can see that they have the top items marked in an unordered list. How are they transforming that list into graphic buttons?
Can you use JavaScript to actually generate graphic buttons instead of using pictures? Is this what they are doing?
Thanks,
Alan
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"With this, the <li>s could be made to be horizontal by adding:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html>
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="" />
<meta name="Author" content="" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<style type="text/css">
body, html {margin:0; padding:0; border:0;} /* Re-sets IE to "zero" for these values */
ul {list-style-type:none; width:500px;}
ul.buttons li a
{display:block; width:70px; color:#000000; background-color:#fde2bb;
padding:6px; padding-left:4px;border-left: 8px solid #00ad63;
border-right:8px solid #00ad63;font: 13px arial, sans-serif;
font-weight: bold; text-decoration: none;text-align: center; margin-top:2px;}
ul.buttons li a:hover
{list-style-type:none;width:66px;background-color:#ffffff;
border-left: 10px solid blue; border-right: 10px solid blue;
font:13px verdana; font-weight: bold; text-decoration:none;}
ul.buttons li a:active {width:66px;background-color:#ffffff;
border-left: 10px solid red; border-right: 10px solid red;
font:13px verdana; font-weight: bold; text-decoration:none;}
</style>
</head>
<body>
<ul class="buttons">
<li><a href="#nogo" title="HOME">Home</a></li>
<li><a href="#nogo" title="Page 2">Page 2</a></li>
<li><a href="#nogo" title="Page 3">Page 3</a></li>
<li><a href="#nogo" title="Page 4">Page 4</a></li>
<li><a href="#nogo" title="Page 5">Page 5</a></li>
</ul>
</body>
</html>[/QUOTE]
ul.buttons li aMuch room for variations of width, height, margins or borders, etc.
{display:block; width:70px; color:#000000; [B]background:#fde2bb[COLOR="Red"]url(standardImage.jpg)[/COLOR] ;[/B]
padding:6px; padding-left:4px;border-left: 8px solid #00ad63;
border-right:8px solid #00ad63;font: 13px arial, sans-serif;
font-weight: bold; text-decoration: none;text-align: center; margin-top:2px;}
ul.buttons li a:hover
{list-style-type:none;width:66px;[B]background:#ffffff[COLOR="Red"]url(hoverImage.jpg)[/COLOR] ;[/B]
border-left: 10px solid blue; border-right: 10px solid blue;
font:13px verdana; font-weight: bold; text-decoration:none;}[/QUOTE]
[CODE]<ul id="menu">
<li><a href="#" title="Go To The Front Page" class="on">Home</a></li>
<li><a href="#" title="Read All About Us">About</a></li>
<li><a href="#" title="View Our Portfolio">Porftolio</a></li>
<li><a href="#" title="Check Out Our Services">Services</a></li>
<li><a href="#" title="Contact Us Here">Contact</a></li>
</ul>[/CODE]
[CODE]/* Menu
------------------------------------------------------------------- */
#menu {
width: 100%;
margin: 0;
padding: 0;
list-style: none;
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
background: #f7f7f7 url(../images/bg_menu.gif) repeat-x left bottom;
border-top: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
}
#menu li {
float: left;
margin: 0;
padding: 0;
font-size: 100%;
}
#menu li a {
float: left;
display: block;
margin: 0;
padding: 6px 20px;
color: #666666;
text-decoration: none;
font-weight: bold;
border-right: 1px solid #DFDFDF;
border-left: 1px solid #F2F2F2;
}
#menu li a:hover {
background: url(../images/bg_menu_hover.gif) repeat-x left bottom;
color: #000000;
}
/* Clearfix */
#menu:after {
content: " ";
display: block;
clear: both;
height: 0;
visibility: hidden;
}[/CODE]
....For the person who mentioned that you can save bandwidth by using small gradient images, I'm not so sure. Look at apple's image that they use for the nav menu. [B]28.78 KB[/B]. And that's the equivalent to 4 different gradients for four diffrent states, and 14 images for 7 buttons (1 out of 4 states is different, black text). ...[/QUOTE]According to websiteoptimization, that apple-dot-com site uses 8 images. The navigation bar images because [I]the text[/I] itself appear to be beveled, are most likely actual button images, not 'gradient slices'. That page is image-heavy (see screenshot). Mostly to show their (very kewl!) products, so understandable and the images are probably highly optimized.
Here is a demo of a drop down menu I made:
http://dev.organixdesign.com/demos/drop_down_menu/
Is that what youre looking for?[/QUOTE]
I dont know .NET, so I cant answer that part, but there are ways to do things like that with CSS only, but browser suppot can be a major issue. I would say, using some good DOM based Javascript, you could achieve accessible, and highly functional sub menus.
Ill see if I can make something like that for my demo site, would be a good thing to have.[/QUOTE]
0.1.9 — BETA 5.19