Finally, My blog got rid of bx-error codes.. come back soon and read the tutorial...
TopBottom

Pure css based tooltip that works with all browsers - blogger hack

Posted by Nitesh Kothari at 18 December 2008 | Post views: counter
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Tool tip can be very useful in terms of site navigation. I searched for pure css tool tips but all in vain. Most of the tutorials, available online, use JavaScript which slows down the loading time of the page. So, I decided to write a tutorial about designing a pure css based tool tip for Blogger. Yeah, you heard it right – Pure css based Tool Tip.

What is tooltip?
As per Wikipedia: The tooltip is a common graphical user interface element. It is used in conjunction with a cursor, usually a mouse pointer. The user hovers the cursor over an item, without clicking it, and a small "hover box" appears with supplementary information regarding the item being hovered over.

Demo: Hover over hereTool tip text appears here

Blogger hack by Nitesh Kothari..


This tooltip works with all browsers. Liked it? Just follow the instruction given below and start using it on your blog.


Step 1: CSS Codes
Copy and paste the following code just above </b:skin>

a.tip {position:relative;}

a.tip span {display: none; position: absolute; top: auto; left: auto; padding: 5px 5px 5px 5px; z-index: 100; background-color: #000; color: #fff; border:0px solid #777; width:200px; height:auto; -moz-border-radius: 2px; -webkit-border-radius: 2px;}

a:hover.tip {font-size: 99%;cursor:pointer;}

a:hover.tip span {display: block;position: absolute;-moz-opacity: 0.7;
opacity:0.7; top:auto; left:auto; right:2px; bottom:auto; line-height:14px; font-size:12px;font-weight:normal;}

Now, i will explain you in detail, how these codes work.
a.tip {position:relative;}

If you specify position:relative, then you can use top or bottom, and left or right to move the element relative to where it would normally occur in the document.

a.tip span {display: none; position: absolute; top: auto; left: auto; padding: 5px 5px 5px 5px; z-index: 100; background-color: #000; color: #fff; width:200px; height:auto;}

This section of css code controls the tool tip text.
display:none - It makes the tool tip text disppear.
position: absolute - When you specify position:absolute, the element is removed from the document and placed exactly where you tell it to go.
background-color: #000 - you can change the background color as per your wish.
color: #fff - This element changes the font's color.
width:200px - Set the width of the tool tip text container.
height:auto - Set the height of the tool tip text container.


a:hover.tip {font-size: 99%;cursor:pointer;}

Here font-size:99% is used for IE browser.
Cursor:pointer - This makes a pointer appear, whenever you hover over the text. you also change it to help.


a:hover.tip span {display: block; position: absolute;-moz-opacity: 0.7;
opacity:0.7; top:auto; left:auto; right:2px; bottom:auto; line-height:auto; font-size:12px;font-weight:normal;}

This is the section that makes the text area appear whenever you hover over the link.

display: block - makes the tool tip visible.
-moz-opacity: 0.7; opacity:0.7; - This makes the tool tip container transparent.
right:2px; - Container will appear 2px left to the link.


Step 2: HTML Code
Check the following example.
<a class='tip' href='#'>more<span>tool tips text area. know more..</span></a>

In the above code, "more" is the link. When you hover over more, the tool tip appears. The text between span tags is what appears in the tool tip.


Final Words
This is one of the best and easiest blogger hack i have written. I hope you like it. Hover over '?' in this blog for a demo. Is it useful for your blog?

Labels:

28 comments:

Vivek Barun said...

This blog's template is one of the best which I have seen on a blogspot blog.
is it premium?
and also the tutorials are great. i have subscribed to your blog.
visit me @
vivekbarunrai.blogspot.com

John said...

This is a neat hack. I wondering now how I can put it to good use. I didn't know about the opacity CSS property, I'm definitely going to play with that! :-)

Nitesh Kothari said...

@vivek:
Thank you for the appreciation.. i designed this template exclusively for my blog.. i plan to launch this blogger template for my readers... thnx for subscribing... wait for some more blogger hacks...

Nitesh Kothari said...

@JOHN:
You have a photo blog... use this hack for pictures on your blog... put some information about the pic using this tooltip..this will add value to your blog pics...

Nitesh Kothari said...

@your pc info:
thnx for bookmarking... expect a better version soon...

Aywren said...

You do an excellent job of breaking this code down for folks (like me) who aren't CSS experts. I had no idea CSS could do that.

This has been spotlighted at my blog! Thanks for a great post!

InvestSound said...

Thanks Nitesh for sharing this css tooltip. I just stumbled upon it :)

http://www.stumbleupon.com/url/www.niteshkothari.com/2008/12/pure-css-based-tooltip-that-works-with.html

Cheers

nikhil said...

Nice prsentation.........but i think there is some thin wrong with the links placed in ya homepage.....

N really u have done somethin unusual by using your own domain on ......u know wat....lol

well most Indians do that......

Nitesh Kothari said...

@nikhil

I think you are also an Indian... dude there is no harm in using ur name as your website domain... u need balls to do that... thnx for appreciation...

Mottobiz said...

Hello Nitesh,

I have installed the first code before bskin as per your guideline. However for the second part- html code.. I am confused. How do I use the html code to show tool tip for one of my links on blogspot posts. What I mean is- I got a word/anchor text "help guide". This anchor text is linked to a site, so how do I add the tooltip to this anchor text word. Sorry I am not a techie person.

I hope this hack doesn't require me to have my own domain, cuz I don't have one!

Anyways, hope you can help me out. You gotta a great site.

God Bless

Nitesh Kothari said...

@mottobiz:

can you be a little specific.. which is the anchor text..what is the tooltip message you want to have or link that you want to connect this tooltip to...

Mottobiz said...

Hello Nitesh,

The anchor text is "poker strategies" and I am linking this text to (http://poker-in-india.blogspot.com/2009/02/explore-step-by-step-poker-guide-to.html).

Here is the tool tip message that I wanna display- "Learn advanced poker tactics with online poker room school"

Hope this will be helpful to answer my particular query.

Thanks again- Awaiting ur reply

Chetan

Chris said...

The box is far away from the link item??

link on left sidebar.. Box appears in right sidebar??

Nitesh Kothari said...

@mottobiz:
ok try this code..

<a class='tip' href='http://poker-in-india.blogspot.com/2009/02/explore-step-by-step-poker-guide-to.html'>poker strategies<span>Learn advanced poker tactics with online poker room school</span></a>

use this code in the post instead of the text only..

Nitesh Kothari said...

@chris:

can you please show me the blog where you used this hack..

sylvain said...

Thanks, fantastic it works. I tried for 3 days, whith one billion different links.

I was looking for something to change the title="" of my pictures with javascript files, but i can't make it works with my blog, i don't know i miss one step each time.

if you know a good one, a blogger tuto would be great.

Nitesh Kothari said...

your welcome sylvain..

you don't need javascript to give title to an image.. you can give title to any image by just using this tag;

alt=''

sylvain said...

Yes, I know that. I'm lazy to copy and paste the alt="blablabla" or title in span blablabla span, but... it's ok. Good effect It doesn't work on IE, i just see the alt= as usual. Any idea?

Gamez-Ring said...

Can you make a recent post tooltip if the mouse in the title referring to the post description will appear post.

if you find something on this, please email to me kurcool3@gmail.com, thank you.


having fun, friend

Prince said...

http://download-movies-free2you.blogspot.com/
http://hot-pictures-bikini.blogspot.com/

suresh said...

Awesome tip .would be very useful
For Movies and Live Cricket
www.andhrajosh.com

Post a Comment

Thank you for commenting at NiteshKothari.com. I follow "U comment I comment" movement. All the comment are dofollow. Please do not spam or leave meaningless or short comments. I expect you to leave me meaningful, relative and genuine comments. Thank you.

Blog Widget by LinkWithin