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;
}
分享到:
相关推荐
横向滚动jQuery导航代码是一款仿FLASH效果的滑动导航菜单代码,站长素材推荐下下载。
2款导航,中英文对照滑动显现jquery导航代码
中英文对照滑动显现jquery导航代码,兼容IE及其他主流浏览器
横向滚动(筋斗云特效)jQuery导航代码 比较简单。
是一个中英文对照滑动显示jquery导航代码,懒人用的方便
横向滚动jQuery导航代码是一款仿FLASH效果的滑动导航菜单代码,站长素材推荐下下载。
横向滚动jQuery导航代码是一款仿FLASH效果的滑动导航菜单代码,站长素材推荐下下载。
jQuery导航图片全屏滚动代码是一款jQuery基于fullPage插件制作响应式的导航下拉菜单和全屏的banner图片轮播代码。
jQuery导航条三级下拉菜单代码
jQuery仿flash导航代码
jQuery 苹果官网导航栏效果代码 jQuery 苹果官网导航栏效果代码
红色的jQuery商城导航菜单代码
jquery+html手机全屏代码,共享给大家
21CN官网jQuery导航 21CN官网jQuery导航菜单代码下载.zip
分享一款大气好看带有背景jQuery自适应横排下拉菜单导航代码给大家,二级菜单的布局可以自由发挥,网站背景请换成你喜欢的。
jquery右侧导航菜单悬浮代码,向下拉动看返回顶部特效,此代码只供学习之用,切勿作非法用途!jquery右侧导航菜单悬浮代码,向下拉动看返回顶部特效,此代码只供学习之用,切勿作非法用途!
两款jquery下拉导航菜单支持多级的下拉导航菜单代码 两款jquery下拉导航菜单支持多级的下拉导航菜单代码 两款jquery下拉导航菜单支持多级的下拉导航菜单代码
jquery导航菜单制作红色商城导航下拉菜单样式代码 jquery导航菜单制作红色商城导航下拉菜单样式代码 jquery导航菜单制作红色商城导航下拉菜单样式代码
jquery实现二级导航,里面包括html,css和javascript代码,下载下来就可以直接使用。