首页 > web前端 > css教程 > 正文

一款漂亮的纯CSS手风琴效果代码

零下一度
发布: 2017-04-21 17:16:15
原创
2659 人浏览过

本文分享了纯css实现的手风琴,喜欢的朋友可以看看

源码CSS部分

.accordionMenu {
			width: 500px;
			margin: 0 auto;
			padding: 10px;
			background-size: #fff;
			color: #424242;
			font: 12px Arial, Verdana, sans-serif;
		}
		.accordionMenu h2 {
			position: relative;
			margin: 5px 0;
			padding: 0;
		}
		.accordionMenu h2:before { /*制作向下三角效果*/
			position: absolute;
			top: 15px;
			right: 10px;
			width: 0;
			height: 0;
			border: 5px solid #fff;
			border-color: #fff transparent transparent;
			content: "";
		}
		.accordionMenu h2 a { /*制作手风琴标题栏效果*/
			background: #8f8f8f;
			background: -moz-linear-gradient(top, #cecece, #8f8f8f);
			background: -webkit-gradinet(linear, left top,left bottom, from(#cecece),to(#8f8f8f));
			background: -webkit-linear-gradient(top, #cecece, #8f8f8f);
			background: -o-linear-gradient(top, #cecece, #8f8f8f);
			background: linear-gradient(top, #cecece, #8f8f8f);
			border-radius: 5px;
			color: #424242;
			display: block;
			font-size: 13px;
			font-weight: normal;
			margin: 0;
			padding: 10px 10px;
			text-shadow: 2px 2px 2px #aeaeae;
			text-decoration: none;
		}
		.accordionMenu :target h2 a, /*目标标题的效果*/
		.accordionMenu h2 a:focus,
		.accordionMenu h2 a:hover,
		.accordionMenu h2 a:active {
			background: #2288dd;
			background: -moz-linear-gradient(top, #6bb2ff, #2288dd);
			background: -webkit-gradinet(linear, left top, left bottom,from(#6bb2ff), to(#2288dd));
			background: -webkit-linear-gradient(top, #6bb2ff, #2288dd);
			background: -o-linear-gradient(top, #6bb2ff, #2288dd);
			background: linear-gradient(top, #6bb2ff, #2288dd);
			color: #fff;
		}
		.accordionMenu p { /* 标题栏对应的内容 */
			overflow: hidden;
			height: 0; /*默认栏目内容高度为0,达到隐藏效果*/
			margin: 0;
			padding: 0 10px;
			-webkit-transition: height 0.5s ease-in;
			-moz-transition: height 0.5s ease-in;
			-o-transition: height 0.5s ease-in;
			transition: height 0.5s ease-in;
		}

		/*关键代码 显示内容部分信息*/
		.accordionMenu :target p { /*展开对应目标内容*/
			overflow: hidden;
			height: 20px;/*显示对应目标栏内容*/
		}

		.accordionMenu :target h2:before { /*展开时标题三角效果*/
			border-color: transparent transparent transparent #fff;
		}
登录后复制

源码html部分

	<p class="accordionMenu">
		<p class="menuSection" id="brand">
			<h2><a href="#brand">Brand</a></h2>
			<p>Lorem ipsum dolor...</p>
		</p>
		<p class="menuSection" id="promotion">
			<h2><a href="#promotion">promotion</a></h2>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
		</p>
		<p class="menuSection" id="Event">
			<h2><a href="#Event">Event</a></h2>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
			<p>Lorem ipsum dolor sit amet...</p>
		</p>
	</p>
登录后复制

更多CSS3特效代码请关注:http://www.php.cn/xiazai/js/CSS3

以上是一款漂亮的纯CSS手风琴效果代码的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板