Easy CSS Tooltip

If you need a really simple and basic Crossbrowser Tooltip on your website, this <1kb tooltip CSS script might be the one for you.

Here is the 4 line magic (3lines css, 1line html):

a:hover {background:#ffffff; text-decoration:none;} /*BG color is a must for IE6*/
a.tooltip span {display:none; padding:2px 3px; margin-left:8px; width:130px;}
a.tooltip:hover span{display:inline; position:absolute; background:#ffffff; border:1px solid #cccccc; color:#6c6c6c;}
Easy &lt;a class=&quot;tooltip&quot; href=&quot;#&quot;&gt;Tooltip&lt;span&gt;This is the crazy little Easy Tooltip Text.&lt;/span&gt;&lt;/a&gt;.

If you want to display a tooltip for a link, just add the class "tooltip" to the link and write your Tooltip Text in a span tag within the a tag - thats it.

Demo

Easy TooltipThis is the crazy little Easy Tooltip Text..

Tested with

IE5, IE 5.5, IE 6, IE7, Safari 3.1, Latest Firefox & Opera Version.

Download this Script

  Easy CSS Tooltip (690 bytes, 23.419 hits)


 

159 Kommentare »

9 Trackbacks

verfasst am 23. August 2008 um 18:59

It's fantastic spent 2 days fumbling with other "simple" apps...any way to disable the actual link so the page won't reload if they click?

Michael

Larry
verfasst am 28. August 2008 um 15:03

Great Tooltip!

I have six icons (3 columns, 2 rows) that are very close to each other. I would like to display a separate tooltip for each. Is there a way to position the tooltips so only one shows and doesn't overlap the others?

Here's what I would like to do:

Top Row

1st Icon - Upper left tooltip
2nd Icon - Top center tooltip
3rd Icon - Top Right tooltip

Bottom Row

1st Icon - Lower Left tooltip
2nd Icon - Bottom center tooltip
3rd icon - Lower right tooltip

Can someone help?

verfasst am 29. August 2008 um 3:46

thank you so much for this script. i never comment on sites, but this is something i have been looking around forever for and felt you deserved the kudos. All the scripts i have found are filled with a lot of things you don't need and actually just end up ruining the code.

verfasst am 9. September 2008 um 14:46

Is there any way to display a text file in the tool tip?

verfasst am 9. September 2008 um 15:41

No its just a css tooltip - if you want to display an external txt file you need a Ajax Tooltip.

verfasst am 15. September 2008 um 0:24

I'm new to webdesign (1 month and counting) and this is perfect for me! easy to figure out and implement. although i am having problems viewing it in IE6. might be b/c i've added a background image to the tooltip? works perfect in MF though! Thanks alot!

polo
verfasst am 18. September 2008 um 13:19

very powerfull, I use it with asp.net, so if I Select sth. like
SELECT ID, '' + cast(ID as varchar(32)) + '' + Title +'' as Text, Title FROM myTable

I have a database depending Tooltip just by binding "text" to any control!

mort
verfasst am 13. Oktober 2008 um 10:05

There is a problem with the z-index i guess, it's always on the top and didn't show any interest on added z-index:xx css tags. :(

Carlos
verfasst am 15. Oktober 2008 um 1:51

Gracias por el script, un saludo desde Nicaragua

verfasst am 21. Oktober 2008 um 14:20

Hi! zetia

Leah
verfasst am 15. Dezember 2008 um 11:10

Hey,

My links are within cells of a dynamically created tabled.

In IE the tooltips are appearing behind the cells which follow.

Any ideas?

verfasst am 15. Dezember 2008 um 12:27

mh you can try to give the "a.tooltip:hover span" class a z-index

Leah
verfasst am 15. Dezember 2008 um 12:45

Hey,

Thanks for the reply I got it working by adding the z-index to the a and the span css.

verfasst am 15. Dezember 2008 um 13:06

Perfect :)

verfasst am 17. Dezember 2008 um 0:09

http://www.hawaii-aloha.com/index1.html this code of tooltip does not work for me.

please see "Find hotels that match your price range" just on the map

please give me some code or if possible let me know whats wong.

Thanks

verfasst am 20. Januar 2009 um 6:38

I'm trying to figure out how to use this with Windows Live Writer- can you help?

Julie
verfasst am 25. Februar 2009 um 21:48

Wow! Thanks so much. Spent all day looking for a Javascript solution and then bump into your site which has it solved with a couple of lines of CSS. Simplicity rules!

verfasst am 3. März 2009 um 1:01

Great code!! So much easier than Javascript solutions. The only thing I wish for is it could do position so it's not using inline. I rather have it next to the word rather than at the end of it. Any ideas?

verfasst am 18. März 2009 um 21:38

Simply GREAT!

verfasst am 30. März 2009 um 12:13

I am sooo going to use this on my site.

verfasst am 23. April 2009 um 12:35

Recently one of my friends started an obsession with the actor Nicholas Cage (mostly because their names are both Nicholas - sounds strange but he is strange and that isn't the point). After asking around the rest of my friends he seems to be a very controversial figure.
What does the forum think? do you love the all action superhero? Or do you hate the droning voice of the man who does nothing but action shooters?

pawan
verfasst am 29. April 2009 um 9:19

thank you so much for this script.

verfasst am 3. Mai 2009 um 18:22

Great!

Using it on my site.

Mike

verfasst am 8. Mai 2009 um 20:35

Thanks! It is very easy, and no js!
:D :D

Tyler Demerchant
verfasst am 26. Juni 2009 um 2:16

First, is you can incorporate javascript into the css by using the DOM.

document.getElementById("tooltip1").innerHTML="This is tooltip1"

ex. Hover me
Using this method, you can hover blocks of text, images, buttons, etc.
Still very simple, but more versatile.

Second, you can have it position how you want to by adding stuff to the style, like block instead of inline for the display and also set the start points within the css.

One problem that is always apparent is that you can end up running off the sides of the page if you use absolute positioning. I am still trying to find a way to use the mouse position to adjust the top left corner during absolute postitioning.

Tyler Demerchant
verfasst am 26. Juni 2009 um 2:22

Oh, it didnt show my html! so much for the example.

verfasst am 2. Juli 2009 um 10:18

Thanks
Kral Fm
KralFm

verfasst am 10. Juli 2009 um 16:35

I realize this post isn't brand-new but just wanted to say...

Great elegant CSS solution! I will definitely use this on future projects.

That said, this doesn't work on floated elements.

Rob
verfasst am 18. Juli 2009 um 14:35

Hi Jurgen,

Thanks for this tip. I used it in my laboratory's site earlier this year and it worked great.

But for some reason it now doesn't work in IE and Chrome (fine in Opera, FireFox and Safari - weird).

I was hoping you might have some ideas why this might be. The page is here: http://www.putslab.psu.edu/research.html The tooltip appears to the right of the graphs.

The CSS is here: http://www.putslab.psu.edu/putsstyle.css with the Tooltip code at the very bottom.

Thanks again,
Rob

verfasst am 28. Juli 2009 um 4:16

http://chinatrip.net.ru china trip China beauty

Seite 2 von 5«12345»
Kommentar schreiben

(erforderlich)

(required but will not be published)

(if you have one)

Bild einfügen:<img src="http://www.website.com/meinbild.jpg" alt="bildbeschreibung" />


 
Produced and © by Koller Jürgen | Powered by the awesome WP | Love and Joy to everyone