jquery 导航 代码

html代码:

<html>
<head>
<link rel="stylesheet" type="text/css" href="jquerycssmenu.css" />

<!--[if lte IE 7]>
<style type="text/css">
html .jquerycssmenu{height: 1%;}
</style>
<![endif]-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript" src="jquerycssmenu.js"></script>

</head>


<body>
<div id="myjquerymenu" class="jquerycssmenu">
<ul>

<li><a href="#">Folder 1</a>
<ul>
<li><a href="#">Sub Item 1.1</a></li>
<li><a href="#">Sub Item 1.2</a></li>
<li><a href="#">Sub Item 1.3</a></li>
<li><a href="#">Sub Item 1.4</a></li>
</ul>
</li>
<li><a href="#">Folder 1</a></li>
</ul>

</div>

</body>
</html>



jquerycssmenu.js代码:



//Specify full URL to down and right arrow images (25 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', 'arrow-down.gif', 25], right:['rightarrowclass', 'arrow-right.gif']}

var jquerycssmenu={

fadesettings: {overduration: 350, outduration: 100}, //duration of fade in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
jQuery(document).ready(function($){
var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){
var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
this.istopheader=$curobj.parents("ul").length==1? true : false
$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
+ '" style="border:0;" />'
)
$curobj.hover(
function(e){
var $targetul=$(this).children("ul:eq(0)")
this._offsets={left:$(this).offset().left, top:$(this).offset().top}
var menuleft=this.istopheader? 0 : this._dimensions.w
menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
$targetul.css({left:menuleft+"px"}).fadeIn(jquerycssmenu.fadesettings.overduration)
},
function(e){
$(this).children("ul:eq(0)").fadeOut(jquerycssmenu.fadesettings.outduration)
}
) //end hover
}) //end $headers.each()
$mainmenu.find("ul").css({display:'none', visibility:'visible'})
}) //end document.ready
}
}

//build menu with ID="myjquerymenu" on page:
jquerycssmenu.buildmenu("myjquerymenu", arrowimages)







jquerycssmenu.css代码:

.jquerycssmenu{
font: bold 12px Verdana;
border-bottom: 1px solid black;
padding-left: 15px;
}

.jquerycssmenu ul{
margin: 0;
padding: 0;
list-style-type: none;
}


.jquerycssmenu ul li{
position: relative;
display: inline;
float: left;
}


.jquerycssmenu ul li a{
display: block;
background: white url(tintblue.gif) top center repeat-x;;
padding: 5px 7px 4px 7px;
margin-right: 3px;
border: 1px solid #778;
border-bottom-width: 0;
color: #2d2b2b;
text-decoration: none;
}

.jquerycssmenu ul li a:hover{
background-image: url(tintbluedark.gif)
}


.jquerycssmenu ul li ul{
position: absolute;
left: 0;
display: block;
visibility: hidden;
border-top: 1px solid black;
}


.jquerycssmenu ul li ul li{
display: list-item;
float: none;
}


.jquerycssmenu ul li ul li ul{
top: 0;
}


.jquerycssmenu ul li ul li a{
font: normal 13px Verdana;
width: 160px;
background: white;
color: black;
padding: 4px 5px;
margin: 0;
border-top-width: 0;
border-bottom: 1px solid black;
}

.jquerycssmenu ul li ul li a:hover{
background: #eff9ff;
color: black;
}



.downarrowclass{
position: absolute;
top: 7px;
right: 5px;
}

.rightarrowclass{
position: absolute;
top: 5px;
right: 5px;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值