Vertical accordion menu by jquery

Written by @kerixa 23 February 2014

Nice, light, low space and perfectjquery vertical menu. Useful for many pages that have a sidebar to show links and content in accordion menu.

Code Snippet:

                                                <!-- this script is provided by coded by: Kerixa Inc. -->
<!-- this script got from by: Krishna Eydat -->
<style type="text/css">
/*Basic reset*/
* {margin: 0; padding: 0;}

body {
	background: #4EB889;
	font-family: Nunito, arial, verdana;
#accordian {
	background: #004050;
	width: 250px;
	margin: 10px auto 0 auto;
	color: white;
	/*Some cool shadow and glow effect*/
		0 5px 15px 1px rgba(0, 0, 0, 0.6), 
		0 0 200px 1px rgba(255, 255, 255, 0.5);
/*heading styles*/
#accordian h3 {
	font-size: 12px;
	line-height: 34px;
	padding: 0 10px;
	cursor: pointer;
	/*fallback for browsers not supporting gradients*/
	background: #003040; 
	background: linear-gradient(#003040, #002535);
/*heading hover effect*/
#accordian h3:hover {
	text-shadow: 0 0 1px rgba(255, 255, 255, 0.7);
/*iconfont styles*/
#accordian h3 span {
	font-size: 16px;
	margin-right: 10px;
/*list items*/
#accordian li {
	list-style-type: none;
#accordian ul ul li a {
	color: white;
	text-decoration: none;
	font-size: 11px;
	line-height: 27px;
	display: block;
	padding: 0 15px;
	/*transition for smooth hover animation*/
	transition: all 0.15s;
/*hover effect on links*/
#accordian ul ul li a:hover {
	background: #003545;
	border-left: 5px solid lightgreen;
/*Lets hide the non active LIs by default*/
#accordian ul ul {
	display: none;
#accordian ul {
	display: block;

<div id="accordian">
			<h3><span class="icon-dashboard"></span>Dashboard</h3>
				<li><a href="#">Reports</a></li>
				<li><a href="#">Search</a></li>
				<li><a href="#">Graphs</a></li>
				<li><a href="#">Settings</a></li>
		<!-- we will keep this LI open by default -->
		<li class="active">
			<h3><span class="icon-tasks"></span>Tasks</h3>
				<li><a href="#">Today's tasks</a></li>
				<li><a href="#">Urgent</a></li>
				<li><a href="#">Overdues</a></li>
				<li><a href="#">Recurring</a></li>
				<li><a href="#">Settings</a></li>
			<h3><span class="icon-calendar"></span>Calendar</h3>
				<li><a href="#">Current Month</a></li>
				<li><a href="#">Current Week</a></li>
				<li><a href="#">Previous Month</a></li>
				<li><a href="#">Previous Week</a></li>
				<li><a href="#">Next Month</a></li>
				<li><a href="#">Next Week</a></li>
				<li><a href="#">Team Calendar</a></li>
				<li><a href="#">Private Calendar</a></li>
				<li><a href="#">Settings</a></li>
			<h3><span class="icon-heart"></span>Favourites</h3>
				<li><a href="#">Global favs</a></li>
				<li><a href="#">My favs</a></li>
				<li><a href="#">Team favs</a></li>
				<li><a href="#">Settings</a></li>

<!-- jquery -->
<script src="" type="text/javascript"></script>
<script type="text/javascript">
/*jQuery time*/
	$("#accordian h3").click(function(){
		//slide up all the link lists
		$("#accordian ul ul").slideUp();
		//slide down the link list below the h3 clicked - only if its closed
<div><a target="_blank" href=""><span style="font-size: 8pt; text-decoration: none">HTML Best Codes</span></a></div>
</html><a target='_blank' href='' style='font-size: 8pt; text-decoration: none'>Html Best Codes</a>                                                


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!



Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

Online Users: 12
Recent Members: sahjahan, fk khan, Proper, Jenisha, Mr Joseph Charles
advertisement 2