Discription Menu

Main >> Content >> Tutorials >> HTML >> Discription Menu

Discription menu is really cool. You can type in a little discription for each page and when you hover it the discription appears under. Here's an example:
Step 1: Start by copying the code under and paste it in your CSS.
#menu{
border: 1px solid #ffffff;
width: 300px;
background-color: #777777;
}

#menu a{
font: normal 10px verdana;
padding: 2px;
padding-left: 4px;
display: block;
width: 100%;
color: black;
text-decoration: none;
border-bottom: 1px solid #ffffff;
}

html>body #menu a{
width: auto;
}

#menu a:hover{
background-color: white;
color: black;
}

#tabledescription{
width: 100%;
height: 3em;
padding: 2px;
filter:alpha(opacity=0);
-moz-opacity:0;
}

Step 2: Now copy the code under and paste it in your header (at the top of the page you want the menu).
<script type="text/javascript">

var baseopacity=0

function showtext(thetext){
if (!document.getElementById)
return
textcontainerobj=document.getElementById("tabledescription")
browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
document.getElementById("tabledescription").innerHTML=thetext
highlighting=setInterval("gradualfade(textcontainerobj)",50)
}

function hidetext(){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
textcontainerobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
textcontainerobj.filters.alpha.opacity=degree
else if (document.getElementById && baseopacity==0)
document.getElementById("tabledescription").innerHTML=""
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=20
else if (window.highlighting)
clearInterval(highlighting)
}

</script>

Step 3: Then copy this code and paste it where you want the menu to be.
<center>
<a href="URL" onMouseover="showtext('Description')" onMouseout="hidetext()">NAME</a>
<a href="URL" onMouseover="showtext('Description')" onMouseout="hidetext()">NAME</a>
<a href="URL" onMouseover="showtext('Description')" onMouseout="hidetext()">NAME</a>
<div id="tabledescription">
</div></div></center>

Step 4: Where it says URL you have to paste the URL of the pages you what to have in the menu, where it says Description you can write a little description of each page you have in the menu, and finally where it says NAME you can type in the names of your pages.

Step 5: The first code you copied is the code that decides the appearences of the menu. Where it says background-color: #606060 you can select another background color by typing in a different color code. If you want to change the width of the menu you have to change this part width: 300px;.
You can also change many other parts of the code, so just take a look at it, get to know it and try different things with it:)

Step 6: If you want more pages in your menu just copy the code under and paste it inside your last code between the div tags.
<a href="URL" onMouseover="showtext('Description')" onMouseout="hidetext()">NAME</a>