jQuery实现的fixedMenu下拉菜单效果代码
作者:bea
本文实例讲述了jQuery实现的fixedMenu下拉菜单效果代码。分享给大家供大家参考。具体如下: 这里演示了仿Google风格的下拉菜单,其核心实际上是jquery.fixedMenu菜单,使用了jquery.fixedMenu.js和fixedMenu_style.css文件,已在代码中加注释,你可以从本代码中分享现这两个文件,然后重新引用。本菜单在鼠标点击主菜单的时候可向下显示二级子菜单,在火狐或Chrome浏览器下,还可显示菜单阴影效果。 运行效果截图如下: 在线
本文实例讲述了jQuery实现的fixedMenu下拉菜单效果代码。分享给大家供大家参考。具体如下:
这里演示了仿Google风格的下拉菜单,其核心实际上是jquery.fixedMenu菜单,使用了jquery.fixedMenu.js和fixedMenu_style.css文件,已在代码中加注释,你可以从本代码中分享现这两个文件,然后重新引用。本菜单在鼠标点击主菜单的时候可向下显示二级子菜单,在火狐或Chrome浏览器下,还可显示菜单阴影效果。
运行效果截图如下:
在线演示地址如下:
http://demo./js/2015/jquery-fixedMenu-menu-style-codes/
具体代码如下:
<!DOCTYPE html>
<head>
<title>jQuery仿Google下拉导航菜单</title>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<style>
/*fixedMenu_style.css代码*/
body{padding: 0;margin: 0;}
.menu{font: 13px/27px Arial,sans-serif;color: #3366CC;height: 30px;background: url(images/back.gif) repeat-x;}
.menu a: hover{background-color: #e4ebf8;}
.menu a{text-decoration: none;padding: 4px 8px 7px;color: #3366CC;outline: none;}
.menu ul{list-style: none;margin: 0;padding: 0 0 0 10px;}
.menu ul li{padding: 0;float: left;}
.menu ul li ul li{padding: 0;float: none;margin: 0 0 0 0px;width: 100%;}
.menu ul li ul{position: absolute;border: 1px solid #C3D1EC;box-shadow: 0 1px 5px #CCCCCC;margin-top: -1px;display: none;padding: 0px 16px 0px 0;}
.active ul{display: block !important;}
.active a{background-color: white;border: 1px solid #C3D1EC;border-bottom: 0;box-shadow: 0 -1px 5px #CCCCCC;display: block;height: 29px;padding: 0 8px 0 8px;position: relative;z-index: 1;}
.active a: hover{background-color: white;}
.active ul a: hover{background-color: #e4ebf8;}
.active ul a{border: 0 !important;box-shadow: 0 0 0 #CCCCCC;border: 0;width: 100%;}
.arrow{border-color: #3366CC transparent transparent;border-style: solid dashed dashed;margin-left: 5px;position: relative;top: 10px;}
</style>
<script>
//jquery.fixedMenu.js文件代码开始
(function($){
$.fn.fixedMenu=function(){
return this.each(function(){
var menu= $(this);
menu.find('ul li > a').bind('click',function(){
if ($(this).parent().hasClass('active')){
$(this).parent().removeClass('active');
}
else{
$(this).parent().parent().find('.active').removeClass('active');
$(this).parent().addClass('active');
}
})
});
}
})(jQuery);
//jquery.fixedMenu.js文件代码结束
$('document').ready(function(){
$('.menu').fixedMenu();
});
</script>
</head>
<body>
<div class="menu">
<ul>
<li>
<a href="#">More Examples<span class="arrow"></span></a>
<ul>
<li><a href="#">Plugins and jQuery Examples</a></li>
<li><a href="#">Prototype Examples</a></li>
<li><a href="#">Mootools Examples</a></li>
<li><a href="#">Javascript Examples</a></li>
</ul>
</li>
<li>
<a href="#">Plugins<span class="arrow"></span></a>
<ul>
<li><a href="#">Galleries</a></li>
<li><a href="#">DropDown Menus</a></li>
<li><a href="#">Content Slider</a></li>
<li><a href="#">LightBox</a></li>
</ul>
</li>
<li>
<a href="#">Friend Sites<span class="arrow"></span></a>
<ul>
<li><a href="#">关于我们</a></li>
<li><a href="#">jquery特效</a></li>
</ul>
</li>
<li>
<a href="#">Contact<span class="arrow"></span></a>
<ul>
<li><a href="#">Follow us on Twitter</a></li>
<li><a href="#">Facebook</a></li>
<li><a href="#">Rss</a></li>
<li><a href="#">e-mail</a></li>
</ul>
</li>
</ul>
</div>
<div style="margin-top:200px;">
</body>
</html>
希望本文所述对大家的jquery程序设计有所帮助。
有用 | 无用
这里演示了仿Google风格的下拉菜单,其核心实际上是jquery.fixedMenu菜单,使用了jquery.fixedMenu.js和fixedMenu_style.css文件,已在代码中加注释,你可以从本代码中分享现这两个文件,然后重新引用。本菜单在鼠标点击主菜单的时候可向下显示二级子菜单,在火狐或Chrome浏览器下,还可显示菜单阴影效果。
运行效果截图如下:
在线演示地址如下:
http://demo./js/2015/jquery-fixedMenu-menu-style-codes/
具体代码如下:
<!DOCTYPE html>
<head>
<title>jQuery仿Google下拉导航菜单</title>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<style>
/*fixedMenu_style.css代码*/
body{padding: 0;margin: 0;}
.menu{font: 13px/27px Arial,sans-serif;color: #3366CC;height: 30px;background: url(images/back.gif) repeat-x;}
.menu a: hover{background-color: #e4ebf8;}
.menu a{text-decoration: none;padding: 4px 8px 7px;color: #3366CC;outline: none;}
.menu ul{list-style: none;margin: 0;padding: 0 0 0 10px;}
.menu ul li{padding: 0;float: left;}
.menu ul li ul li{padding: 0;float: none;margin: 0 0 0 0px;width: 100%;}
.menu ul li ul{position: absolute;border: 1px solid #C3D1EC;box-shadow: 0 1px 5px #CCCCCC;margin-top: -1px;display: none;padding: 0px 16px 0px 0;}
.active ul{display: block !important;}
.active a{background-color: white;border: 1px solid #C3D1EC;border-bottom: 0;box-shadow: 0 -1px 5px #CCCCCC;display: block;height: 29px;padding: 0 8px 0 8px;position: relative;z-index: 1;}
.active a: hover{background-color: white;}
.active ul a: hover{background-color: #e4ebf8;}
.active ul a{border: 0 !important;box-shadow: 0 0 0 #CCCCCC;border: 0;width: 100%;}
.arrow{border-color: #3366CC transparent transparent;border-style: solid dashed dashed;margin-left: 5px;position: relative;top: 10px;}
</style>
<script>
//jquery.fixedMenu.js文件代码开始
(function($){
$.fn.fixedMenu=function(){
return this.each(function(){
var menu= $(this);
menu.find('ul li > a').bind('click',function(){
if ($(this).parent().hasClass('active')){
$(this).parent().removeClass('active');
}
else{
$(this).parent().parent().find('.active').removeClass('active');
$(this).parent().addClass('active');
}
})
});
}
})(jQuery);
//jquery.fixedMenu.js文件代码结束
$('document').ready(function(){
$('.menu').fixedMenu();
});
</script>
</head>
<body>
<div class="menu">
<ul>
<li>
<a href="#">More Examples<span class="arrow"></span></a>
<ul>
<li><a href="#">Plugins and jQuery Examples</a></li>
<li><a href="#">Prototype Examples</a></li>
<li><a href="#">Mootools Examples</a></li>
<li><a href="#">Javascript Examples</a></li>
</ul>
</li>
<li>
<a href="#">Plugins<span class="arrow"></span></a>
<ul>
<li><a href="#">Galleries</a></li>
<li><a href="#">DropDown Menus</a></li>
<li><a href="#">Content Slider</a></li>
<li><a href="#">LightBox</a></li>
</ul>
</li>
<li>
<a href="#">Friend Sites<span class="arrow"></span></a>
<ul>
<li><a href="#">关于我们</a></li>
<li><a href="#">jquery特效</a></li>
</ul>
</li>
<li>
<a href="#">Contact<span class="arrow"></span></a>
<ul>
<li><a href="#">Follow us on Twitter</a></li>
<li><a href="#">Facebook</a></li>
<li><a href="#">Rss</a></li>
<li><a href="#">e-mail</a></li>
</ul>
</li>
</ul>
</div>
<div style="margin-top:200px;">
</body>
</html>
希望本文所述对大家的jquery程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jquery实现的淡入淡出下拉菜单效果
- iframe中子父类窗口调用JS的方法及注意事项
- JavaScript+CSS实现仿天猫侧边网页菜单效果
- 14款经典网页图片和文字特效的jQuery插件-前端开发必备
- jquery实现向下滑出的二级导航下滑菜单效果
- jquery插件tytabs.jquery.min.js实现渐变TAB选项卡效果
- js文本框走动跑马灯效果代码分享
- jQuery合作伙伴左右滚动特效
- JS+CSS实现滑动切换tab菜单效果
- jquery图片滚动放大代码分享(1)
- jquery实现在网页指定区域显示自定义右键菜单效果
- jquery实现的3D旋转木马特效代码分享
- jQuery+CSS实现的网页二级下滑菜单效果
- jQuery实现点击小图显示大图代码分享
- 基于jquery实现select选择框内容左右移动添加删除代码分享
- jquery实现鼠标经过显示下划线的渐变下拉菜单效果代码
- 基于jQuery实现在线选座之高铁版
- jQuery实现TAB风格的全国省份城市滑动切换效果代码
- jquery实现像栅栏一样左右滑出式二级菜单效果代码