本文实例讲述了JS实现黑色大气的二级导航菜单效果。分享给大家供大家参考。具体如下:

这是一款自己做的不错的二级导航菜单,黑色风格,是根据仿淘宝支付宝菜单而做的,自我感觉还算行吧。

运行效果截图如下:

JS实现黑色大气的二级导航菜单效果

在线演示地址如下:

http://demo.jb51.net/js/2015/js-black-style-2l-nav-menu-codes/

具体代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>多级导航菜单</title>
<style>
strong {
 font-style: normal;
 font-weight: normal;
 font-weight: bold;
}
a {
 cursor: pointer;
 text-decoration: none;
}
#container {
 width: 960px;
 margin: 0pt auto;
}
#nav, .nav-container, .nav-container ul, #nav .nav-master-a:hover, #nav .nav-master-a:hover strong, #nav li.current .nav-master-a strong, #nav li.current .nav-master-a, #nav .nav-sub a:hover, #nav .nav-sub a:hover span {
 background-image: url('images/bg-nav.gif');
 background-repeat: no-repeat;
}
#nav {
 position: relative;
 height: 66px;
 margin: 5px 0pt 0pt;
 background-position: 0pt -230px;
 background-repeat: repeat-x;
}
.nav-container {
 padding-left: 15px;
 height: 66px;
 background-position: 0pt 0pt;
}
.nav-container ul {
 height: 100%;
 background-position: right -66px;
}
.nav-container ul ul.nav-sub {
 background: none repeat scroll 0% 0% transparent;
 height: auto;
}
.nav-master {
 display: block;
 float: left;
 height: 36px;
 width: 100px;
 line-height: 36px;
 text-align: center;
 padding-right: 4px;
}
.nav-master-a {
 display: block;
 font-size: 14px;
 height: 26px;
 line-height: 26px;
 overflow: hidden;
 background: none repeat scroll 0% 0% transparent;
 text-decoration: none;
 margin-top: 5px;
}
.nav-master-a strong {
 display: block;
 color: rgb(255, 255, 255);
 height: 100%;
}
li.current .nav-master-a strong, #nav li.current .nav-master-a:hover strong {
 color: rgb(0, 0, 0);
}
.nav-master-a:hover {
 text-decoration: none;
 background-position: 0pt -315px;
}
.nav-master-a:hover strong {
 background-position: right -360px;
}
#nav li.current .nav-master-a strong {
 background-position: right -180px;
 padding-top: 2px;
}
#nav li.current .nav-master-a {
 background-position: 0pt -131px;
 overflow: hidden;
 color: rgb(0, 0, 0);
 height: 31px;
}
#nav li.current .nav-master-a:hover strong {
 color: rgb(0, 0, 0);
}
ul.nav-sub {
 position: absolute;
 width: 920px;
 text-align: left;
 top: 38px;
 left: 20px;
 display: none;
 padding: 2px 0pt 0pt;
 background: none repeat scroll 0% 0% transparent;
}
#nav .current .nav-sub {
 display: block;
}
.nav-sub li {
 float: left;
 display: block;
 width: 78px;
 text-align: center;
 height: 30px;
 overflow: hidden;
 margin-right: 4px;
}
#nav .nav-sub a {
 display: block;
 height: 22px;
 overflow: hidden;
 color: rgb(77, 77, 77);
 text-decoration: none;
}
#nav .nav-sub a span {
 display: block;
 line-height: 22px;
 height: 22px;
}
#nav .nav-sub a:hover {
 background-position: 0pt -405px;
}
#nav .nav-sub a:hover span {
 background-position: right -446px;
}
.sp-nav {
 overflow:hidden;
 background: url(images/bg-nav.gif) repeat-x 0 -595px;
 height:31px;
 line-height:31px
}
.sp-con {
 color:#CCC;
 margin:0 auto;
 width:968px;
}
.sp-l {
 overflow:hidden;
 float:left;
 background:url(images/bg-nav.gif) no-repeat 0 -558px;
 width:6px;
 height:31px
}
.sp-r {
 overflow:hidden;
 float:right;
 background:url(images/bg-nav.gif) no-repeat -6px -558px;
 height:31px;
 width:6px;
}
.sp-m {
 position:relative;
 padding:0 10px;
 float:left;
 background:url(images/bg-nav.gif) repeat-x 0 -495px;
 height:31px;
 line-height:31px;
 width:936px;
 color:#000;
 text-align: left;
}
.other {
 float: left;
 height: 23px;
 margin-right: 22px;
 display: inline;
}
.so {
 float: right;
 padding-top: 6px;
 height: 26px;
}
.so .inputstyleso {
 width: 89px;
 height: 16px;
 line-height: 16px;
 border: 1px solid rgb(190, 190, 190);
 float: left;
 padding-top: 2px;
 padding-left: 5px;
}
.so img {
 float: left;
 margin: 2px 4px 0pt 0pt;
 display: inline;
}
</style>
</head>
<body>
<script language="javascript">
var waitInterval2;
var MDelayTime2=300;/* 设置延时0.3秒 */
function qiehuan(num){
clearTimeout(waitInterval2);
waitInterval2=window.setTimeout("qiehuan2("+num+");",MDelayTime2);
}
function qiehuan2(num){
 clearTimeout(waitInterval2);
 for(var id = 0;id<=9;id++)
 {
 if(id==num)
  {
   document.getElementById("qh_con"+id).style.display="block";
   document.getElementById("mynav"+id).className="nav-master current";
  }
 else
  {
   document.getElementById("qh_con"+id).style.display="none";
   document.getElementById("mynav"+id).className="nav-master";
  }
 }
}
</script>
 <div id="nav">
 <div class="nav-container">
 <ul>
 <li class="nav-master current" id="mynav0"><a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(0)"><strong>首页</strong></a>
  <ul class="nav-sub" id="qh_con0">
  <li><a href="#"><span>最近更新</span></a></li>
  <li><a href="#"><span>热门推荐</span></a></li>
  <li><a href="#"><span>周下载榜</span></a></li>
  <li><a href="#"><span>月下载榜</span></a></li>
  <li><a href="#"><span>相关教程</span></a></li>
  <li><a href="#"><span>美化软件</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav1"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(1)"><strong>xp主题</strong></a>
  <ul class="nav-sub" id="qh_con1">
  <li><a href="#"><span>美女明星</span></a></li>
  <li><a href="#"><span>影视动漫</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>颜色专题</span></a></li>
  <li><a href="#"><span>3D金属</span></a></li>
  <li><a href="#"><span>节日游戏</span></a></li>
  <li><a href="#"><span>汽车体育</span></a></li>
  <li><a href="#"><span>风景设计</span></a></li>
  <li><a href="#"><span>苹果系统</span></a></li>
  <li><a href="#"><span>透明专题</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav2"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(2)"><strong>vista主题</strong></a>
  <ul class="nav-sub" id="qh_con2">
  <li><a href="#"><span>完美套装</span></a></li>
  <li><a href="#"><span>动漫影视</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>美女主题</span></a></li>
  <li><a href="#"><span>3D系列</span></a></li>
  <li><a href="#"><span>汽车主题</span></a></li>
  <li><a href="#"><span>风景主题</span></a></li>
  <li><a href="#"><span>黑色主题</span></a></li>
  <li><a href="#"><span>创意设计</span></a></li>
  <li><a href="#"><span>系统主题</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav3"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(3)"><strong>win7主题</strong></a>
  <ul class="nav-sub" id="qh_con3">
  <li><a href="#"><span>完美套装</span></a></li>
  <li><a href="#"><span>风景主题</span></a></li>
  <li><a href="#"><span>动漫影视</span></a></li>
  <li><a href="#"><span>汽车主题</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>设计主题</span></a></li>
  <li><a href="#"><span>黑色主题</span></a></li>
  <li><a href="#"><span>精美推荐</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav4"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(4)"><strong>屏幕保护</strong></a>
  <ul class="nav-sub" id="qh_con4">
  <li><a href="#"><span>泡泡</span></a></li>
  <li><a href="#"><span>湖泊瀑布</span></a></li>
  <li><a href="#"><span>动物植物</span></a></li>
  <li><a href="#"><span>3D、游戏</span></a></li>
  <li><a href="#"><span>影视卡通</span></a></li>
  <li><a href="#"><span>时钟</span></a></li>
  <li><a href="#"><span>恐怖</span></a></li>
  <li><a href="#"><span>节日、艺术</span></a></li>
  <li><a href="#"><span>水馆族</span></a></li>
  <li><a href="#"><span>自然风光</span></a></li>
  <li><a href="#"><span>太空、火焰</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav5"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(5)"><strong>系统图标</strong></a>
  <ul class="nav-sub" id="qh_con5">
  <li><a href="#"><span>IP包</span></a></li>
  <li><a href="#"><span>苹果</span></a></li>
  <li><a href="#"><span>系统硬件</span></a></li>
  <li><a href="#"><span>生活</span></a></li>
  <li><a href="#"><span>游戏</span></a></li>
  <li><a href="#"><span>节日</span></a></li>
  <li><a href="#"><span>卡通</span></a></li>
  <li><a href="#"><span>文件夹</span></a></li>
  <li><a href="#"><span>回收站</span></a></li>
  <li><a href="#"><span>软件</span></a></li>
  <li><a href="#"><span>手机数码</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav6"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(6)"><strong>鼠标指针</strong></a>
  <ul class="nav-sub" id="qh_con6">
  <li><a href="#"><span>动漫鼠标</span></a></li>
  <li><a href="#"><span>透明系列</span></a></li>
  <li><a href="#"><span>精美特色</span></a></li>
  <li><a href="#"><span>CursorFx/Xp</span></a></li>
  <li><a href="#"><span>鼠标特效</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav7"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(7)"><strong>桌面壁纸</strong></a>
  <ul class="nav-sub" id="qh_con7">
  <li><a href="#"><span>3D、创意</span></a></li>
  <li><a href="#"><span>美女明星</span></a></li>
  <li><a href="#"><span>动物植物</span></a></li>
  <li><a href="#"><span>风景、日历</span></a></li>
  <li><a href="#"><span>节日系列</span></a></li>
  <li><a href="#"><span>影视动漫</span></a></li>
  <li><a href="#"><span>游戏卡通</span></a></li>
  <li><a href="#"><span>PSP、手绘</span></a></li>
  <li><a href="#"><span>炫彩抽象</span></a></li>
  <li><a href="#"><span>人文建筑</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav8"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(8)"><strong>其它美化</strong></a>
  <ul class="nav-sub" id="qh_con8">
  <li><a href="#"><span>启动界面</span></a></li>
  <li><a href="#"><span>登陆界面</span></a></li>
  <li><a href="#"><span>vista边栏</span></a></li>
  <li><a href="#"><span>梦幻桌面</span></a></li>
  <li><a href="#"><span>系统声音</span></a></li>
  <li><a href="#"><span>精选美化包</span></a></li>
  <li><a href="#"><span>相关教程</span></a></li>
  <li><a href="#"><span>美化软件</span></a></li>
  </ul>
 </li>
 </ul>
 </div>
 </div>
</body>
</html>

希望本文所述对大家的JavaScript程序设计有所帮助。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。