Home » jQuery

jQuery: Cool Bouncing Navigation with easing plugin

5 February 2010 68 views No Comment

Here, I will be showing you how to create a cool bouncing navigation with jQuery and jQuery easing plugin. The content appears with the bouncing effect as you navigate through the menu.

You need jQuery Library and the jQuery easing plugin. But you need not worry, I have zipped them all in the download file.

View Demo || Download Code

Basically, there are 3 parts – CSS, HTML and Javascript.

Here is the HTML part:-

<div id="container" align="center">
	<h2>Bouncing Navigation</h2>

	<div id="navigation">
		<a class="home" href="#">Home</a>
		<a class="contact" href="#">Contact</a>
		<a class="links" href="#">Links</a>
		<a class="about" href="#">About</a>
	</div>
	<br/>

	<div class="content home"><h3>Home</h3></div>
	<div class="content contact hide"><h3>Contact</h3></div>
	<div class="content links hide"><h3>Links</h3></div>
	<div class="content about hide"><h3>About</h3></div>		

</div>
<div style="border-bottom: 1px solid #CCCCCC"></div>

In the HTML part, the div with id=navigation contains menus. And the div with the class=content contains the content data related with each menu. By default, only the home content is shown. The rest of others are made hidden.

The displaying, hiding, padding, maintaining width, height, font color, background color, etc. are controlled by CSS. Here is the CSS part:-

#container {
	padding: 10px;
	min-height: 350px;
}
#navigation a {
	text-decoration: none;
	padding: 10px;
	color: #F3F3F3;
}
#navigation a:hover {
	text-decoration: underline;
}
.home {
	background: #0292C0;
}
.contact {
	background: #6AA63B;
}
.links {
	background: #D52100;
}
.about {
	background: #FBC700;
}
.content {
	border: 1px solid #336699;
	width: 300px;
	height: 300px;
	padding: 10px;
	color: #F3F3F3;
}
.hide {
	display: none;
}

The bouncing effect is performed through Javascript.

$(function(){
	$("#navigation a").click(function(){
		$(".content."+$(this).attr("class")).animate({height: "1px"},50);
		$("[class^=content]").addClass("hide");
		$("[class^=content]").removeAttr("style");
		$(".content."+$(this).attr("class")).animate({height: "300px"},{duration: 1000, easing: "easeOutBounce"});
	});
});

In the JS code above, the effect is performed when the a href link of div id=navigation is clicked. Here are the steps performed:-
– make the height of content to 1px with animate function.
– add class hide to all div with class content
– remove style attribute from the div with class content
– animate the div content to the height 300px with easeOutBounce effect (This effect is one of the effects of jQuery easing plugin. This gives the bouncing effect.)

That’s all we need for the cool bouncing navigation effect.

View Demo || Download Code

Cheers,

Popularity: 6%

Related posts:

  1. Making a tree navigation menu in PHP
  2. jQuery: Animate and Transfer effect with Image
  3. jQuery: Preview Image with Zoom Effect
  4. jQuery: Grey out background and preview image as popup
  5. jQuery: Preview Image with Tooltip Effect
Share/Bookmark
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.