O.K. I'm creating a simple menu for a web page as a way to learn some of the more interesting DHTML techniques and methods, and also because I didn't like the samples I could find.
First, the resluting menu looks and functions well (animation as desired, but I haven't added functional links yet). It is nicely centered on the page. However, I would like it to stay at the top of the web browser, and have the page contents scroll behind it when the user scrolls through the page contents. Anone know how to do that with the most simplicity?
Second, I have 5 very similar DIV declarations in the BODY of the HTML. Is there a simple way to change this to use less code? Something like a javascript loop to create sequentially numbered elements? Or can the 'onMousOver' and 'onMouseOut' references be added to the STYLE declaration?
Any feedback would be greatly appreciated.
Here's the code so-far:
- James.
My memory is not as good as it should be, and neither is my memory.
I have forgotten more than I can remember
First, the resluting menu looks and functions well (animation as desired, but I haven't added functional links yet). It is nicely centered on the page. However, I would like it to stay at the top of the web browser, and have the page contents scroll behind it when the user scrolls through the page contents. Anone know how to do that with the most simplicity?
Second, I have 5 very similar DIV declarations in the BODY of the HTML. Is there a simple way to change this to use less code? Something like a javascript loop to create sequentially numbered elements? Or can the 'onMousOver' and 'onMouseOut' references be added to the STYLE declaration?
Any feedback would be greatly appreciated.
Here's the code so-far:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<HTML><HEAD>
<TITLE>Test Menu</TITLE>
<STYLE type="text/css">
<!--
.MenuContainer
{ position:fixed; Overflow:visible; top:0px; Width:495px; height:145px;
border:2px; padding:0px; margin:0px; visibility:visible;
background-color:transparent;
}
.MenuBanner
{ position:fixed; overflow:hidden; width:493px; height:97px;
background-color:green; visibility:visible; border:0px;
}
.MenuTab
{ position:fixed; visibility:visible; overflow:hidden;
margin:0px; border:0px; padding;0px; float:left;
width: 98px; height: 50px; display:inline;
background-color: transparent;
background-image: url(SmallMenuTab.gif);
background-position: top center;
color: white; text-align: center; vertical-align: bottom;
font-family:cursive; font-variant:small-caps;
font-weight:bolder; font-size:100%;
}
.BodyStyle
{ Margin-top:1px;
}
-->
</STYLE>
<SCRIPT type="text/javascript">
<!-- hide script from old browsers
function ActiveMenuButton(ButtonName)
{ ButtonName.style.color='yellow';
ButtonName.style.fontSize='150%';
ButtonName.style.backgroundImage='url(LargeMenuTab.gif)'
}
function InactiveMenuButton(ButtonName)
{ ButtonName.style.color='white';
ButtonName.style.fontSize='100%';
ButtonName.style.backgroundImage='url(SmallMenuTab.gif)'
}
-->
</SCRIPT>
</HEAD>
<BODY ID="MainBody" CLASS="BodyStyle">
<center><DIV ID="MainMenu" CLASS="MenuContainer">
<DIV ID="LogoBanner" CLASS="MenuBanner">
<IMG SRC="CompanyLogo.gif" ALT="Company Logo">
</DIV>
<DIV ID="MenuButton1" CLASS="MenuTab"
onMouseOver=ActiveMenuButton(MenuButton1);
onMouseOut=InactiveMenuButton(MenuButton1) >
Menu1
</DIV>
<DIV ID="MenuButton2" CLASS="MenuTab"
onMouseOver=ActiveMenuButton(MenuButton2);
onMouseOut=InactiveMenuButton(MenuButton2) >
Menu2
</DIV>
<DIV ID="MenuButton3" CLASS="MenuTab"
onMouseOver=ActiveMenuButton(MenuButton3);
onMouseOut=InactiveMenuButton(MenuButton3) >
Menu3
</DIV>
<DIV ID="MenuButton4" CLASS="MenuTab"
onMouseOver=ActiveMenuButton(MenuButton4);
onMouseOut=InactiveMenuButton(MenuButton4) >
Menu4
</DIV>
<DIV ID="MenuButton5" CLASS="MenuTab"
onMouseOver=ActiveMenuButton(MenuButton5);
onMouseOut=InactiveMenuButton(MenuButton5) >
Menu5
</DIV>
</DIV></center>
</BODY></HTML>
- James.
My memory is not as good as it should be, and neither is my memory.
I have forgotten more than I can remember