设为首页收藏本站关注微信<<< 抵制 IE6 人人有责 >>>
搜索
热搜: 活动 交友 discuz
查看: 2493|回复: 1
打印 上一主题 下一主题

[Jquery] 自动收缩的手风琴jQuery导航菜单

[复制链接]
跳转到指定楼层
楼主
发表于 2015-9-24 00:18:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[HTML] 纯文本查看 复制代码
<html xml:lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta name="Copyright" content="www.kevin-ying.com" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<link href="http://www.kevin-ying.com/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<script type="text/javascript" src="http://www.kevin-ying.com/jq/jquery-2.1.4.min.js"></script>

<title>jQuery淡入淡出、展开收缩菜单 | 源与生活 站长工具 by:文歌提供([url]www.kevin-ying.com[/url])</title>
<script type="text/javascript">
$(function(){
	//菜单隐藏展开
	var tabs_i=0
	$('.vtitle').click(function(){
		var _self = $(this);
		var j = $('.vtitle').index(_self);
		if( tabs_i == j ) return false; tabs_i = j;
		$('.vtitle em').each(function(e){
			if(e==tabs_i){
				$('em',_self).removeClass('v01').addClass('v02');
			}else{
				$(this).removeClass('v02').addClass('v01');
			}
		});
		$('.vcon').slideUp().eq(tabs_i).slideDown();
	});
})
</script>
<style type="text/css">
* {
	margin:0;
	padding:0;
	list-style-type:none;
}
a, img {
	border:0;
}
body {
	font:12px/180% Arial, Helvetica, sans-serif, "新宋体";
}
a, a:hover {
	text-decoration: none;
}
/*收缩菜单*/
.v {
	float:right;
	width:14px;
	height:14px;
	overflow:hidden;
	background:url(vicon.png) no-repeat;
	display:inline-block;
	margin-top:-5px;
	margin-bottom:-5px;
}
.v01 {
	background-position:0 0;
}
.v02 {
	background-position:0 -16px;
	;
}
.vtitle {
	height:35px;
	background:#fbede0;
	line-height:35px;
	border:1px solid #ccb6a9;
	margin-top:-1px;
	padding-left:20px;
	font-size:15px;
	color:#4d4d4d;
	font-family:"\5FAE\8F6F\96C5\9ED1";
	cursor:pointer;
}
.vtitle em {
	margin:10px 10px 0 0;
}
.vconlist {
	background:#9cc;
}
.vconlist li a {
	height:30px;
	line-height:30px;
	padding-left:30px;
	display:block;
	font-size:14px;
	color:#866f67;
	font-family:"\5FAE\8F6F\96C5\9ED1";
}
.vconlist li.select a, .vconlist li a:hover {
	color:#ed4948;
	text-decoration:none;
}
</style>
</head>
<body>
<div style="width:268px;margin:30px auto 0 auto;">
  <div class="vtitle"><em class="v v02"></em>源码下载</div>
  <div class="vcon">
    <ul class="vconlist clearfix">
      <li class="select"><a href="javascript:;">Flash源码</a></li>
      <li><a href="javascript:;">Ajax源码</a></li>
      <li><a href="javascript:;">Java源码</a></li>
    </ul>
  </div>
  <div class="vtitle"><em class="v"></em>网页特效</div>
  <div class="vcon" style="display: none;">
    <ul class="vconlist clearfix">
      <li><a href="javascript:;">菜单代码</a></li>
      <li><a href="javascript:;">广告代码</a></li>
      <li><a href="javascript:;">表格特效</a></li>
    </ul>
  </div>
  <div class="vtitle"><em class="v"></em>编程学院</div>
  <div class="vcon" style="display: none;">
    <ul class="vconlist clearfix">
      <li><a href="javascript:;">服务器</a></li>
      <li><a href="javascript:;">数据库</a></li>
      <li><a href="javascript:;">Winform</a></li>
    </ul>
  </div>
</div>
<div style="text-align:center;clear:both"></div>
</body>
</html>

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享淘帖
回复

使用道具 举报

沙发
 楼主| 发表于 2015-9-24 00:24:46 | 只看该作者
[HTML] 纯文本查看 复制代码
<html xml:lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta name="Copyright" content="www.kevin-ying.com" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<link href="http://www.kevin-ying.com/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<script type="text/javascript" src="http://www.kevin-ying.com/jq/jquery-2.1.4.min.js"></script>
<title>CSS3垂直手风琴折叠菜单</title>
<script>
$(function() {
	var Accordion = function(el, multiple) {
		this.el = el || {};
		this.multiple = multiple || false;

		// Variables privadas
		var links = this.el.find('.link');
		// Evento
		links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
	}

	Accordion.prototype.dropdown = function(e) {
		var $el = e.data.el;
			$this = $(this),
			$next = $this.next();

		$next.slideToggle();
		$this.parent().toggleClass('open');

		if (!e.data.multiple) {
			$el.find('.submenu').not($next).slideUp().parent().removeClass('open');
		};
	}	

	var accordion = new Accordion($('#accordion'), false);
});
</script>
<style>
* {
	margin: 0;
	padding: 0;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}

body {
	background: #2d2c41;
	font-family: 'Open Sans', Arial, Helvetica, Sans-serif, Verdana, Tahoma;
}

ul {
	list-style-type: none;
}

a {
	color: #b63b4d;
	text-decoration: none;
}

/** =======================
 * Contenedor Principal
 ===========================*/
 .accordion {
 	width: 100%;
 	max-width: 360px;
 	margin: 30px auto 20px;
 	background: #FFF;
 	-webkit-border-radius: 4px;
 	-moz-border-radius: 4px;
 	border-radius: 4px;
 }

.accordion .link {
	cursor: pointer;
	display: block;
	padding: 15px 15px 15px 42px;
	color: #4D4D4D;
	font-size: 14px;
	font-weight: 700;
	border-bottom: 1px solid #CCC;
	position: relative;
	-webkit-transition: all 0.4s ease;
	-o-transition: all 0.4s ease;
	transition: all 0.4s ease;
}

.accordion li:last-child .link {
	border-bottom: 0;
}

.accordion li i {
	position: absolute;
	top: 16px;
	left: 12px;
	font-size: 18px;
	color: #595959;
	-webkit-transition: all 0.4s ease;
	-o-transition: all 0.4s ease;
	transition: all 0.4s ease;
}

.accordion li i.fa-chevron-down {
	right: 12px;
	left: auto;
	font-size: 16px;
}

.accordion li.open .link {
	color: #b63b4d;
}

.accordion li.open i {
	color: #b63b4d;
}
.accordion li.open i.fa-chevron-down {
	-webkit-transform: rotate(180deg);
	-ms-transform: rotate(180deg);
	-o-transform: rotate(180deg);
	transform: rotate(180deg);
}

/**
 * Submenu
 -----------------------------*/
 .submenu {
 	display: none;
 	background: #444359;
 	font-size: 14px;
 }

 .submenu li {
 	border-bottom: 1px solid #4b4a5e;
 }

 .submenu a {
 	display: block;
 	text-decoration: none;
 	color: #d9d9d9;
 	padding: 12px;
 	padding-left: 42px;
 	-webkit-transition: all 0.25s ease;
 	-o-transition: all 0.25s ease;
 	transition: all 0.25s ease;
 }

 .submenu a:hover {
 	background: #b63b4d;
 	color: #FFF;
 }

</style>
</head>

<body>

<!-- Contenedor -->
<ul id="accordion" class="accordion">
	<li>
		<div class="link"><i class="fa fa-paint-brush"></i>Diseño web<i class="fa fa-chevron-down"></i></div>
		<ul class="submenu">
			<li><a href="#">Photoshop</a></li>
			<li><a href="#">HTML</a></li>
			<li><a href="#">CSS</a></li>
			<li><a href="#">Maquetacion web</a></li>
		</ul>
	</li>
	<li>
		<div class="link"><i class="fa fa-code"></i>Desarrollo front-end<i class="fa fa-chevron-down"></i></div>
		<ul class="submenu">
			<li><a href="#">Javascript</a></li>
			<li><a href="#">jQuery</a></li>
			<li><a href="#">Frameworks javascript</a></li>
		</ul>
	</li>
	<li>
		<div class="link"><i class="fa fa-mobile"></i>Diseño responsive<i class="fa fa-chevron-down"></i></div>
		<ul class="submenu">
			<li><a href="#">Tablets</a></li>
			<li><a href="#">Dispositivos mobiles</a></li>
			<li><a href="#">Medios de escritorio</a></li>
			<li><a href="#">Otros dispositivos</a></li>
		</ul>
	</li>
	<li><div class="link"><i class="fa fa-globe"></i>Posicionamiento web<i class="fa fa-chevron-down"></i></div>
		<ul class="submenu">
			<li><a href="#">Google</a></li>
			<li><a href="#">Bing</a></li>
			<li><a href="#">Yahoo</a></li>
			<li><a href="#">Otros buscadores</a></li>
		</ul>
	</li>
</ul>

</body>
</html>



回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

QQ|手机版|Archiver|源于生活(个人生活娱乐工作的笔记)css3,html5,学习笔记    

GMT+8, 2024-11-23 20:56 , Processed in 0.140400 second(s), 26 queries .

Powered by Mr.Kevin-ying

© 2004-2015

快速回复 返回顶部 返回列表