JQuery伸縮導(dǎo)航練習(xí)示例
更新時間:2013年11月13日 15:53:25 作者:
伸縮的導(dǎo)航有不少優(yōu)點的,可以在有限的空間里容下很多的內(nèi)容,下面有個不錯的示例用到JQuery,感興趣的朋友可以參考下
最近在學(xué)習(xí)JQuery,嘗試制作了這個導(dǎo)航
下載:代碼
<!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>伸縮導(dǎo)航</title>
<link rel="stylesheet" type="text/css" href="nav.css">
<script type="text/javascript" src="jquery-1.10.2.js"></script>
<script type="text/javascript" src="nav.js"></script>
</head>
<body>
<div class="navigator">
<ul class="tabs">
<li class="tab1">
<h3>導(dǎo)航卡1</h3>
<ul class="nav1">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
<li class="tab2">
<h3>導(dǎo)航卡2</h3>
<ul class="nav2">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
<li class="tab3">
<h3>導(dǎo)航卡3</h3>
<ul class="nav3">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
/**
* Author LY 2013-11-11 22:30
**/
* {
margin: 0;
padding: 0;
font-family: "Microsoft Yahei","Arial"
}
.navigator {
width: 180px;
display: block;
margin-top: 30px;
margin-left: 30px;
border-top: 10px solid #ddd;
border-bottom: 10px solid #ddd;
border-left: 3px solid #ddd;
border-right: 3px solid #ddd;
background: #ddd;
}
.tabs {
list-style: none;
}
.tabs li {
clear: both;
overflow: auto;
}
.tabs li h3 {
padding: 0;
margin:0;
font-size: 14px;
height: 40px;
line-height: 40px;
text-align: center;
width: 180px;
cursor: pointer;
background: #07f;
color: #fff;
border-bottom: 1px solid #ccc;
}
.tabs li:last-child h3 {
border:none;
}
.tabs li h3.current {
background: #6af;
}
.tabs li ul {
margin-left: auto;
margin-right: auto;
width: 160px;
height: 0px;
list-style: none;
overflow: hidden;
}
.tabs li ul li {
height: 30px;
line-height: 30px;
background: #eee;
padding: 5px;
border-bottom: 1px solid #ccc;
cursor: pointer;
}
$(document).ready(function(){
$(".nav1").css("height","160px");
$(".tabs li h3:first").addClass("current");
$(".tabs li h3").click(function() {
$(".tabs li h3").removeClass("current");
$(this).addClass("current");
$(".tabs li ul").animate({height:"0"},"fast");
$(this).next().animate({height:"160"},"slow");
});
});

下載:代碼
復(fù)制代碼 代碼如下:
<!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>伸縮導(dǎo)航</title>
<link rel="stylesheet" type="text/css" href="nav.css">
<script type="text/javascript" src="jquery-1.10.2.js"></script>
<script type="text/javascript" src="nav.js"></script>
</head>
<body>
<div class="navigator">
<ul class="tabs">
<li class="tab1">
<h3>導(dǎo)航卡1</h3>
<ul class="nav1">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
<li class="tab2">
<h3>導(dǎo)航卡2</h3>
<ul class="nav2">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
<li class="tab3">
<h3>導(dǎo)航卡3</h3>
<ul class="nav3">
<li>子項目1</li>
<li>子項目2</li>
<li>子項目3</li>
<li>子項目4</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
復(fù)制代碼 代碼如下:
/**
* Author LY 2013-11-11 22:30
**/
* {
margin: 0;
padding: 0;
font-family: "Microsoft Yahei","Arial"
}
.navigator {
width: 180px;
display: block;
margin-top: 30px;
margin-left: 30px;
border-top: 10px solid #ddd;
border-bottom: 10px solid #ddd;
border-left: 3px solid #ddd;
border-right: 3px solid #ddd;
background: #ddd;
}
.tabs {
list-style: none;
}
.tabs li {
clear: both;
overflow: auto;
}
.tabs li h3 {
padding: 0;
margin:0;
font-size: 14px;
height: 40px;
line-height: 40px;
text-align: center;
width: 180px;
cursor: pointer;
background: #07f;
color: #fff;
border-bottom: 1px solid #ccc;
}
.tabs li:last-child h3 {
border:none;
}
.tabs li h3.current {
background: #6af;
}
.tabs li ul {
margin-left: auto;
margin-right: auto;
width: 160px;
height: 0px;
list-style: none;
overflow: hidden;
}
.tabs li ul li {
height: 30px;
line-height: 30px;
background: #eee;
padding: 5px;
border-bottom: 1px solid #ccc;
cursor: pointer;
}
復(fù)制代碼 代碼如下:
$(document).ready(function(){
$(".nav1").css("height","160px");
$(".tabs li h3:first").addClass("current");
$(".tabs li h3").click(function() {
$(".tabs li h3").removeClass("current");
$(this).addClass("current");
$(".tabs li ul").animate({height:"0"},"fast");
$(this).next().animate({height:"160"},"slow");
});
});
您可能感興趣的文章:
- jquery實現(xiàn)點擊向下展開菜單項(伸縮導(dǎo)航)效果
- jQuery實現(xiàn)的動態(tài)伸縮導(dǎo)航菜單實例
- jquery入門—編寫一個導(dǎo)航條(可伸縮)
- jquery實現(xiàn)可點擊伸縮與展開的菜單效果代碼
- jquery實現(xiàn)選中單選按鈕下拉伸縮效果
- jQuery實現(xiàn)首頁頂部可伸縮廣告特效代碼
- jQuery照片伸縮效果不影響其他元素的布局
- jQuery使用一個按鈕控制圖片的伸縮實現(xiàn)思路
- 使用jQuery同時控制四張圖片的伸縮實現(xiàn)代碼
- JQuery 圖片的展開和伸縮實例講解
- jquery實現(xiàn)頂部向右伸縮的導(dǎo)航區(qū)域代碼
相關(guān)文章
jquery.cvtooltip.js 基于jquery的氣泡提示插件
顯示氣泡提示的前提是,一定會有一個被提示的對象,默認(rèn)的位置是根據(jù)body來計算的,這樣的壞處就是如果頁面內(nèi)容發(fā)生了變化,而氣泡的位置沒有改變,導(dǎo)致提示目的失敗。2010-11-11使用jquery的ajax需要注意的地方dataType的設(shè)置
沒有設(shè)置dataType:'json',就出現(xiàn)無法解析返回的data數(shù)據(jù),會把data當(dāng)作字符串處理,而不是json對象,記得以前是不用設(shè)dataType的,很奇怪,不知道是不是跟jquery版本有關(guān)系2013-08-08jQuery 調(diào)用WebService 實例講解
以前都是Web程序調(diào)用WebService,.net把WebService封裝的太簡單了,所以之前都是很膚淺的用,都沒有想過更深層的東西,并且只是停留在表面的添加引用和調(diào)用。2016-06-06遍歷json獲得數(shù)據(jù)的幾種方法小結(jié)
下面小編就為大家?guī)硪黄闅vjson獲得數(shù)據(jù)的幾種方法小結(jié)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01基于jquery實現(xiàn)頁面滾動時頂部導(dǎo)航顯示隱藏
這篇文章主要介紹了基于jquery實現(xiàn)頁面滾動時頂部導(dǎo)航顯示隱藏效果,當(dāng)頁面向下滾動的時候,導(dǎo)航菜單動態(tài)隱藏,頁面滾動到頂部時,導(dǎo)航菜單動態(tài)顯示,淘寶也采用過此效果,感興趣的小伙伴們可以參考一下2015-11-11