Social Icons With Cool jQuery Tooltip

This tutorial will take you through how to create a simple jQuery animated tooltip for social icons such as RSS and Twitter. It shows you how to achieve a nice faded animation that you can change variables such as fade speeds etc. All you need is two images and jQuery!

Final Result

The Files That You Will Need

demo
download

Step 1

js files

In your js folder make sure you have the two files: jquery.js which you can download here, and a blank tooltip.js which we will be adding our own javascript to.

Step 2

$(document).ready(function(){

		$(".rsstooltip a").hover(function() {
		$(this).next("em").stop(true, true).animate({opacity: "show", top: "-60"}, "slow");
		}, function() {
		$(this).next("em").animate({opacity: "hide", top: "-70"}, "fast");
		});

		});

$(document).ready(function(){

		$(".twittertooltip a").hover(function() {
		$(this).next("em").stop(true, true).animate({opacity: "show", top: "-60"}, "slow");
		}, function() {
		$(this).next("em").animate({opacity: "hide", top: "-70"}, "fast");
		});

		});

Inside your blank toolip.js file add this javascript. It may look like a lot, however the code is repeated twice with the variable of the RSS & Twitter logo is changed.

Step 3

		<link rel="stylesheet" href="css/style.css" type="text/css"/>
		<script src="js/jquery.js" type="text/javascript"></script>
		<script src="js/tooltip.js" type="text/javascript"></script>

Link your style.css, jquery.js and tooltip.js files to the index.html file in the head tags.

Step 4

	<!-- RSS -->
		<div class="rsstooltip">
			<a href="#" id="rss-icon"></a>
			<em>RSS/em>
		</div>
	<!-- RSS End -->

	<!-- Twitter -->
		<div class="twittertooltip">
			<a href="#" id="twitter-icon"></a>
			<em>Twitter</em>
		</div>
	<!-- Twitter End -->

In your html body add the following code. Give the social icon a wrapping div, within this have your icon div and then your em tag – this will be the bubble that appears on the mouse over. If you check our tooltip.js we coded earlier you will find the variables and divs/classes match this html code. Where the # appears in the anchor tag – replace with your required links.

Step 5

/* RSS */

.rsstooltip {
	   margin: 115px auto;
	   padding: 0;
	   width: 100px;
	   position: relative;
}

.rsstooltip em {
	   background: url(../images/rssbubble.jpg) no-repeat;
	   width: 109px;
	   height: 51px;
	   position: absolute;
	   top: -70px;
	   left: -110px;
	   text-align: center;
	   text-indent: -9999px;
	   z-index: 2;
	   display: none;
}

#rss-icon {
	   width: 72px;
	   height: 71px;
	   background: url(../images/rss.jpg) no-repeat 0 0;
	   text-indent: -9999px;
	   margin: 0 -90px;
	   display: block;
	   opacity: 0.85;
	   float: left;
}

#rss-icon:hover {
	   opacity: 1.0;
}

Now we need to style the html that was just coded. Set the following css to your stylesheet. For each social icon you have you will need to change the class/div names and background images of the icon and em tag. One little effect you can add is to the icons opacity/opacity hover which will work with webkit capable browsers – this will save on the sprites!

All Done

Thats all it takes to get super cool jQuery animated bubble tooltips! If you enjoyed this post, have a alternative way to gain the same effect or have an opinion be sure to comment below. Sharing of this post would also be appreciated.

demo
download

henrydurdan

About Author..

Henry Durdan is a web designer from the United Kingdom, he loves all things design and loves learning new things about the design world. Henry also does product reviews, technology related obviously! to find out more head to the about page of the site! You can also follow Henry on Twitter.

This entry was posted on Sunday, November 15th, 2009 at 9:01 am and is filed under Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Responses

  1. December 10th, 2009 at 1:39 pm

    Social Icons With Cool jQuery Tooltip…

    This tutorial will take you through how to create a simple jQuery animated tooltip for social icons such as RSS and Twitter….

    Reply to this comment
  2. December 10th, 2009 at 3:58 pm

    I wasn’t able to get this to sit in a div in my sidebar, it took up too much height.

    What is controlling the overall height required?

    Reply to this comment
  3. December 13th, 2009 at 9:17 am

    Great post. I will be using this effect on my website, except for a faster loading time I am working on a version based off of your code that uses text & styling to display all of the info, instead of several different images.

    Reply to this comment
  4. December 15th, 2009 at 7:01 pm

    @Pliggs: There is an unnecessary margin-top property that was added. I think Henry has it there because it makes it work with the layout that you download, but if you’ve edited it, it will work without that.

    Reply to this comment
  5. Emre
    May 15th, 2010 at 3:31 pm

    Hi,
    I’m from Turkiye, I cant edit bubbles images for translation. Do you share .psd files, please?

    Reply to this comment

Leave Your Response