带有悬停图像的子导航栏



我正在创建一个带有图像的水平顶部导航栏。我已经准备好了顶部栏(下面的代码),但我不确定如何添加第二级和第三级导航。例如,当有人在Business Essentials上悬停时,我希望图像本身更改为悬停状态,并在其下方显示一个表,这是我的子导航。也许我的做法不对,但使用图像是我获得所需确切外观的唯一方法。如果有人能告诉我下一步应该是什么,或者给我一个参考/示例代码,我将不胜感激。

<head>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-   2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src;  x.src=a[i+2];}
}
</script>
</head>

<body onload="MM_preloadImages('Nav2_hover.jpg','Nav3_hover.jpg','Nav4_hover.jpg','Nav5_hover.jpg','Nav6_hover.jpg','Nav7_hover.jpg','Nav8_hover.jpg','Nav9_hover.jpg')">
<table width="950" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="194"><img src="Nav1.jpg" width="194" height="67" alt="Home" longdesc="/home.aspx" /></td>
<td width="70"><a href="/bus_essentials.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('BusEssentials','','Nav2_hover.jpg',1)"><img src="Nav2.jpg" alt="Business Essentials" width="70" height="67" id="BusEssentials" /></a></td>
<td width="9"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="68"><a href="/career_planning.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('CareerPlanning','','Nav3_hover.jpg',1)"><img src="Nav3.jpg" alt="Career Planning" width="68" height="67" id="CareerPlanning" /></a></td>
<td width="9"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="108"><a href="/communications.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Communications','','Nav4_hover.jpg',1)"><img src="Nav4.jpg" alt="Communications" width="108" height="67" id="Communications" /></a></td>
<td width="9"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="95"><a href="/ind_effectiveness.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('IndivEffectiveness','','Nav5_hover.jpg',1)"><img src="Nav5.jpg" alt="Individual Effectiveness" width="95" height="67" id="IndivEffectiveness" /></a></td>
<td width="9"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="84"><a href="/leadership.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Leadership','','Nav6_hover.jpg',1)"><img src="Nav6.jpg" alt="Leadership" width="84" height="67" id="Leadership" /></a></td>
<td width="10"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="77"><a href="/mentoring.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Mentoring','','Nav7_hover.jpg',1)"><img src="Nav7.jpg" alt="Mentoring" width="77" height="67" id="Mentoring" /></a></td>
<td width="182"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="9"><a href="/effectiveness.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Effectiveness','','Nav8_hover.jpg',1)"><img src="Nav8.jpg" alt="Effectiveness" width="99" height="67" id="Effectiveness" /></a></td>
<td width="182"><img src="NavDiv.jpg" width="9" height="67" /></td>
<td width="17"><a href="/skills.aspx" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Skills','','Nav9_hover.jpg',1)"><img src="Nav9.jpg" alt="Skills" width="93" height="67" id="Skills" /></a></td>
</tr>
</table>

大约有一百万个jquery脚本和教程可以做到这一点,而不需要付出所有的努力来编写代码。我不知道这是否可行,但在谷歌上快速搜索后发现:

http://www.webdesigndev.com/web-development/create-the-fanciest-dropdown-menu-you-ever-saw

相关内容

  • 没有找到相关文章

最新更新