DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery常見問題 >> jQuery向上彈出導航菜單
jQuery向上彈出導航菜單
編輯:JQuery常見問題     
jQuery向上彈出導航菜單 效果預覽:
導航1
子導航1
導航2
子導航1
子導航1
子導航1
子導航1
導航3
子導航1
子導航1
子導航1
導航4
子導航1
子導航1
子導航1
子導航1


另外推薦的彈出菜單:
jQuery UI 菜單
更多菜單
向上彈出菜單插件首頁
keleyi菜單0.1.5版本發布了

jQuery向上彈出導航菜單 完整代碼:

<!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=gbk" />
<title>jQuery實現的向上彈出的仿flash效果的導航菜單</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background:#FC0 url(img/1.jpg);
}
a {
color:#FFF;
font-size:13px;
text-decoration:none;
}
#wrap {
margin:300px auto 0;
width:600px;
position:relative;
}
#navwrap {
width:600px;
height:50px;
background:#000;
position:absolute;
bottom:0;
left:0;
overflow:hidden;
}
#navwrap dl {
margin:10px;
_margin:10px 0;
width:120px;
color:#FFF;
float:left;
_width:140px;
_overflow:hidden;
}
#navwrap dl dt {
padding:0 10px;
height:26px;
line-height:26px;
width:100px;
}
#navwrap dl dt a {
font-weight:bold;
}
#navwrap dl dt a:hover {
color:#FF0;
}
#navwrap dl dd {
margin-left:-10px;
padding:0 10px;
height:20px;
line-height:20px;
width:120px;
display:none;
position:relative;
}
#navwrap dl dd a {
font-size:12px;
position:absolute;
width:120px;
height:20px;
top:0;
}
#navwrap dl dd span {
margin-left:-5px;
width:130px;
height:20px;
display:block;
background:#333;
}
</style>
</head>
<body>
<div id="wrap">
<div id="navwrap">
<dl>
<dt class="mover"><a href="#">導航1</a></dt>
<dd><span></span><a href="#">子導航1</a></dd>
</dl>
<dl>
<dt><a href="#">導航2</a></dt>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
</dl>
<dl>
<dt><a href="#">導航3</a></dt>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="http://">子導航1</a></dd>
</dl>
<dl>
<dt><a href="#">導航4</a></dt>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="#">子導航1</a></dd>
<dd><span></span><a href="http://">子導航1</a></dd>
</dl>
</div>
</div>
<div id="test" style="margin:0 auto; width:96%;word-wrap:break-word;"></div>
<script type="text/javascript" src="http:///keleyi/pmedia/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
/**********Power By Mulder*********/
/*********www.***********/
/**********2008-11-19**************/
var wrapminh = 50; //nav框架高度
var wrapmaxh = 200; //nav框架變化後高度
var wraptime = 10; //nav變化間隔
var wrapspace = 10; //nav變化距離
var wraptemp = wrapminh; //nav現時高度
var wrapslideup = false; //false:下; true:上;
var wrapLock = false; //
var wrapmovieobj = ''; //主層動畫
var wrapopacity = ''; //主層透明度
$('#navwrap').css('opacity','0.4');
$('#navwrap dl dd span').css('opacity','0');
$('#navwrap dl dd a').css('opacity','1');
wrapmouse();
ddmouse();
function ddmouse(){
$('#navwrap dd').hover(function(){
ddnum = $('#navwrap dd').index(this);
ddoutLock = false;
ddLock = false;
ddlidemovie()
},function(){
ddoutLock = true;
ddLock = false;
ddlidemovie()
});
}

var ddmovieobj = '';
var ddLock = false;
var ddoutLock = false;
var ddnum = '';

function ddslide(){
var total = $('#navwrap dd').length;
for(i=0;i<total;i++){
var ddopacity = $('#navwrap dd:eq('+i+') span').css('opacity');
ddopacity = Number(ddopacity.replace(/[^\- \. 0-9]+/g, ''));
if(ddoutLock){
if(ddopacity > 0){
$('#navwrap dd:eq('+i+') span').css('opacity',Number((ddopacity*10 - 1)/10));}
if(ddnum == i && ddopacity <= 0){
//$('#test').append('第'+i+'個:'+ddopacity+ddLock+' ');
ddLock = true;}
}else{
if(i != ddnum){
if(ddopacity > 0){
$('#navwrap dd:eq('+i+') span').css('opacity',Number((ddopacity*10 - 1)/10));}
}else{
if(ddopacity < 0.9){
$('#navwrap dd:eq('+i+') span').css('opacity',Number((ddopacity*10 + 1)/10));}else{
ddLock = true;
}
}
}
}


}
function ddlidemovie(){
clearInterval(ddmovieobj);
if(ddLock)return;
ddslide();
ddmovieobj = setInterval('ddlidemovie();',10);
}

//wrap鼠標經過
function wrapmouse(){
$('#navwrap').hover(function(){
wrapslideup = true;
wrapLock = false;
wrapslidemovie();
}, function(){
wrapslideup = false;
wrapLock = false;
wrapslidemovie();
});
}
// wrap動
function wrapslidemovie(){
clearInterval(wrapmovieobj);
if(wrapLock)return;
if(wraptemp >= wrapminh && wraptemp <= wrapmaxh){
wrapslide();
wrapmovieobj = setInterval('wrapslidemovie();',wraptime);
}
if(wraptemp < wrapminh){
wraptemp = wrapminh + wrapspace;
wrapslide();
wrapLock = true;}
if(wraptemp > wrapmaxh){
wraptemp = wrapmaxh - wrapspace;
wrapslide();
wrapLock = true;}
}
//主層動畫
function wrapslide(){
if(wrapslideup){
wraptemp += wrapspace;
if(wrapopacity < 0.8){
wrapopacity = Number(wrapopacity + 0.1);
}
}else{
wraptemp -= wrapspace;
if(wrapopacity > 0.4){
wrapopacity = Number(wrapopacity - 0.1);
}
}
if(wraptemp == wrapmaxh){
$('#navwrap dl dd').css('display','block');
subnavup = true;
subnavLock = false;
subnavmovie();
}else{
subnavup = false;
subnavLock = false;
subnavmovie();
$('#navwrap dl dd').css('display','none');
}
//$('#test').append(wrapopacity+' ');
$('#navwrap').css('opacity',wrapopacity);
$('#navwrap').css('height',wraptemp);
}


function subnavmovie(){
clearInterval(subnavmovieobj);
if(subnavLock)return;
if(subnavtemp >= -10 && subnavtemp <= 0){
subnavslide();
subnavmovieobj = setInterval('subnavmovie();',wraptime);
}
}
//子導航動畫
var subnavup = false;
var subnavtemp = -10;
var subnavmovieobj = '';
var subnavLock = false;
function subnavslide(){
if(subnavup){
if(subnavtemp < 0){
subnavtemp = Number(subnavtemp + 1); }
//alert('here');
}else{
if(subnavtemp > -10){
subnavtemp = Number(subnavtemp - 1); }
}
if(subnavtemp == -10 || subnavtemp ==0){subnavLock = true;}
//$('#test').append(subnavtemp+' ');
$('#navwrap dl dd').css('margin-left',subnavtemp);
}
</script>
</body>
</html>


這是另一個向上菜單:http:///a/bjac/xc8g7uiy.htm
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved