首頁 > web前端 > js教程 > 基於dropdown.js實現的兩款美觀大氣的二級導航選單_javascript技巧

基於dropdown.js實現的兩款美觀大氣的二級導航選單_javascript技巧

WBOY
發布: 2016-05-16 15:41:09
原創
1390 人瀏覽過

本文實例講述了基於dropdown.js實現的兩款美觀大氣的二級導航選單。分享給大家供大家參考。具體如下:

1. 藍色風格導航選單

運作效果截圖如下:

線上示範網址如下:

http://demo.jb51.net/js/2015/js-dropdown-blue-style-nav-menu-codes/

具體程式碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>漂亮的js+css横向二级导航条-蓝色</title>
<style>
body{padding:0px;margin:0px;}
body{font-family:Arial, Helvetica, sans-serif;font-size:14px;background-color:#fff;}
ul,li{padding:0px;margin:0px;list-style-type: none;}
a{text-decoration: none;color:#003971;}
a:hover{color:#000;}
/*导航菜单*/
#navMenu {width:960px;margin:20px auto;height: 44px;line-height: 44px;display:block;overflow:hidden;background: url(images/_nav_bg.jpg) repeat-x ;}
#navMenu ul{width:95%;padding-left:8px;background:url(images/_nav_l.jpg) no-repeat;float:left;}
#navMenu .onelink{background-image:none;}
#navMenu_r{padding-right:8px;background:url(images/_nav_r.jpg) no-repeat right ;float:right;height:44px;}
#navMenu li {width:108px;text-align:center;float: left;line-height:44px;height: 44px;background-image: url(images/_nav_fg.jpg);  background-repeat: no-repeat;background-position: 0 center;  margin-left: -2px;}
#navMenu li a {  color:#fff;font-family: "宋体";padding-right: 1em;padding-left: 1em;margin-left: 2px;display: block;}
#navMenu li a:hover{background: url(images/_nav_hover.jpg) no-repeat center;  text-decoration: none;color:#FFf;}
/*-------- 下拉菜单 --------------*/
.dropMenu {  position:absolute;top: 0;z-index:100;width: 164px;visibility: hidden; margin-top: -2px;margin-left:-2px;}
.dropMenu li.end { background:url(images/_sub_bottom.jpg) no-repeat;padding-left:6px;height:12px;}
.dropMenu li {background:url(images/_sub_bg.jpg);padding:8px 0 0 6px;  }
.dropMenu li a {width: 92%;  display: block;  text-align:center;  color: black;padding: 5px 0 5px 0px;color:#000;  }
.dropMenu a:hover {text-decoration: underline;color:#003971;}
</style>
</head>
<body>
<br/><br/>
<p style="text-align:center;color:#000;font-size:15px;">js+css横向二级导航条--蓝色</p>
<br/><br/>
<div id="navMenu">
<ul>
 <li class="onelink"><a href='/'>主页</a></li>
 <li><a href='#'>HTML+CSS</a></li>
 <li><a href='#' rel='dropmenu1'>JS代码</a></li>
 <li><a href='#' rel='dropmenu2'>电子商务</a></li>
 <li><a href='#' >SEO优化</a></li>
 <li><a href='#' rel='dropmenu3'>建站技巧</a></li>
 <li><a href='#'>零度对策</a></li>
 <li><a href='#'>网络营销</a></li>
 </ul>
  <div id="navMenu_r"></div>
</div>
<script type='text/javascript' src='images/dropdown.js'></script>
<ul id="dropmenu1" class="dropMenu">
 <li><a href="#">导航菜单</a></li>
 <li><a href="#">焦点幻灯片</a></li>
 <li><a href="#">网页特效</a></li>
 <li><a href="#">广告代码</a></li>
  <li class="end"></li>
</ul>
<ul id="dropmenu2" class="dropMenu">
 <li><a href="#">企业类网站</a></li>
 <li><a href="#">行业类网站</a></li>
 <li><a href="#/">BLOG类网站</a></li>
 <li><a href="#">门户类网站</a></li>
 <li><a href="#">商城类网站</a></li>
  <li class="end"></li>
</ul>
<ul id="dropmenu3" class="dropMenu">
 <li><a href="#">HTML技巧</a></li>
 <li><a href="#">CSS技巧</a></li>
 <li><a href="#">CMS建站技巧</a></li>
 <li><a href="#">其他技巧</a></li>
  <li class="end"></li>
</ul>
<script type="text/javascript">cssdropdown.startchrome("navMenu")</script> 
<!--//nav-->
<br><br><br><br><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/>
</div>
</body>
</html>
登入後複製

2. 桔黃色風格導覽選單

運作效果截圖如下:

線上示範網址如下:

http://demo.jb51.net/js/2015/js-dropdown-orange-style-nav-menu-codes/

具體程式碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>桔黄色漂亮的js+css二级菜单代码</title>
<style>
body{padding:0px;margin:0px;}
body{font-family:Arial, Helvetica, sans-serif;font-size:14px;background-color:#2f2f2f;}
ul,li{padding:0px;margin:0px;list-style-type: none;}
a{text-decoration: none;color:#CFE0EE;}
a:hover{color:#Fff;}
#navMenu {width:960px;margin:20px auto;height: 44px;line-height: 44px;display:block;overflow:hidden;background: url(images/nav_bg.jpg) repeat-x ;}
#navMenu ul{width:95%;padding-left:8px;background:url(images/nav_l.jpg) no-repeat;float:left;}
#navMenu .onelink{background-image:none;}
#navMenu_r{padding-right:8px;background:url(images/nav_r.jpg) no-repeat right ;float:right;height:44px;}
#navMenu li {width:108px;text-align:center;float: left;line-height:44px;height: 44px;background-image: url(images/nav_fg.jpg);  background-repeat: no-repeat;background-position: 0 center;  margin-left: -2px;}
#navMenu li a {color:#fff;font-family: "宋体";padding-right: 1em;padding-left: 1em;margin-left: 2px;display: block;}
#navMenu li a:hover{background: url(images/nav_hover.jpg) no-repeat center;
text-decoration: none;color:#FFf;}
/*-------- 下拉菜单 --------------*/
.dropMenu {  position:absolute;top: 0;z-index:100;width: 164px;visibility: hidden; margin-top: -4px;margin-left:-2px;}
.dropMenu li.end { background:url(images/sub_bottom.jpg) no-repeat;padding-left:6px;height:12px;}
.dropMenu li {background:url(images/sub_bg.jpg);padding:8px 0 0 6px;  }
.dropMenu li a {
width: 92%;  display: block;
text-align:center;
color: black;padding: 5px 0 5px 0px;color:#000;
}
.dropMenu a:hover {text-decoration: underline;color:#fa6e00;}
</style>
</head>
<body>
<br/><br/>
<p style="text-align:center;color:#fff;font-size:15px;">js+css横向二级导航条--桔黄色</p>
<br/><br/>
<div id="navMenu">
<ul>
 <li class="onelink"><a href='#' target="_blank">主页</a></li>
 <li><a href='#' target="_blank">HTML+CSS</a></li>
 <li><a href='#' rel='dropmenu1' target="_blank">JS代码</a></li>
 <li><a href='#' rel='dropmenu2' target="_blank">电子商务</a></li>
 <li><a href='#' >SEO优化</a></li>
 <li><a href='#' rel='dropmenu3' target="_blank">建站技巧</a></li>
 <li><a href='#' target="_blank">零度对策</a></li>
 <li><a href='#' target="_blank">网络营销</a></li>
 </ul>
  <div id="navMenu_r"></div>
</div>
<script type='text/javascript' src='images/dropdown.js'></script>
<ul id="dropmenu1" class="dropMenu">
 <li><a href="#" target="_blank">导航菜单</a></li>
 <li><a href="#" target="_blank">焦点幻灯片</a></li>
 <li><a href="#" target="_blank">网页特效</a></li>
 <li><a href="#" target="_blank">广告代码</a></li>
  <li class="end"></li>
</ul>
<ul id="dropmenu2" class="dropMenu">
 <li><a href="#" target="_blank">企业类网站</a></li>
 <li><a href="#" target="_blank">行业类网站</a></li>
 <li><a href="#/" target="_blank">BLOG类网站</a></li>
 <li><a href="#" target="_blank">门户类网站</a></li>
 <li><a href="#" target="_blank">商城类网站</a></li>
  <li class="end"></li>
</ul>
<ul id="dropmenu3" class="dropMenu">
 <li><a href="#" target="_blank">HTML技巧</a></li>
 <li><a href="#" target="_blank">CSS技巧</a></li>
 <li><a href="#" target="_blank">CMS建站技巧</a></li>
 <li><a href="#" target="_blank">其他技巧</a></li>
  <li class="end"></li>
</ul>
<script type="text/javascript">cssdropdown.startchrome("navMenu")</script> 
</div>
</body>
</html>
登入後複製

希望本文所述對大家的javascript程式設計有所幫助。

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板