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, 26.099 hits)


 

160 Kommentare »

9 Trackbacks

verfasst am 17. März 2010 um 9:36

For all they have problems try this version of the script: http://www.hot-elle.de/2007-02-21/css-onmouseover-tooltippopup/

Chaos Crafter
verfasst am 19. März 2010 um 4:32

It's worth noting thatt he critical detail for ie6 is that the background color (or possibly any other item that requires a whole-object re-render) must change.
So if you had a.tooltip {background:#ffffff;}
in the above example it would fail because with no change in the background no redraw occurs of the previously hidden span.
I haven't experimented with it, but I suspect anything that forces a redraw of the whole A tag will make the difference.
Another one that does work is
a.tooltip {zoom:1;}
a.tooltip:hover {zoom:1.0001;}
(A warning though, zoom:1.00001 doesn't work as it is rounded to 1, and 1.001 could be enough to perform a visible resizing of a full-screen-width panel.)

dario
verfasst am 19. März 2010 um 16:14

what a beauty ! there's so many jquery tooltips out there but the simplicity of this is just too cool ... muchas gracias !

Stephan
verfasst am 24. März 2010 um 17:36

Hi, nice tip, it works great.

But now I discovered a problem. I use tooltips on a form page, which might be printed by the user. At the moment all tooltips are displayed on printout. I didn't found any way to hide them.

Any ideas. Thanks.

Stephan
verfasst am 25. März 2010 um 14:32

Just found the solution. To avoid any printout of the tooltip just add:

@media print { span {display:none;} }

If you might use span anywhere else, this items might not be printed either.

Michel
verfasst am 4. April 2010 um 9:13

Thanks a lot men.... I am very happy with this great tooltip. The first that is easy to build in (for me).

Jean-Philippe Martin
verfasst am 7. April 2010 um 16:44

Just to say thanks. This a great !

Anil
verfasst am 18. Juni 2010 um 10:22

Thanks a lot... very nice... :)

verfasst am 29. Juli 2010 um 3:49

so smart (h) , we can put an html in it of course

thanks for that

verfasst am 12. August 2010 um 14:27

Hallo.
Dein Post ist ja schon was älter aber ich möchte einen kleinen Kommentar loswerden.
Dein Code funktioniert nicht in Webkit Browsern wie CHROME (IRON) oder SAFARI .
es gibt einen Konflikt mit
display: inline;
und
position: absolute;
im span style.
Beide beziehen sich auf Positionierung von Elementen und jeder Browser rendert das anders. (Ähnliche Probleme gibt es bei Anwendung von float, position und / oder display auf das selbe Element.
Wenn du erlaubst, hier der code der auch in Webkit Browsern funktioniert:

Easy CSS Tooltip - by Kollermedia.at; altered by therealanodyne

/* Easy CSS Tooltip - by Koller Juergen [www.kollermedia.at]; improved by therealanodyne */
* {font-family: Verdana, Arial, Helvetica, sans-serif; font-size:15px; }
a.tooltip {
position: relative;
left: 300px;
top: 100px;
}
a.tooltip:hover {
background: #ffffff; /*BG color is a must for IE6*/
text-decoration: none;
}
a.tooltip span {
display: none;
padding: 2px 3px;
border: 1px solid #cccccc;
background: #fff; color:#6c6c6c;
width: 130px;
}
a.tooltip: hover span {
display: block;
position: absolute;
left: 100%; /*or more for some margin-left*/
top: 0%;
}

Easy TooltipThis is the crazy little Easy Tooltip
Text.
.

Für Erscheinen des Tooltips unter dem Link (oder beliebigen anderen Elementen in modernen Browsern):

a.tooltip: hover span {
display: block;
position: absolute;
left: 0;
top: 100%; /*or more for some margin-bottom*/
}

Vor oder über dem Link ist ebenfalls möglich jedoch nicht flexibel, da die Positionierung von width des Link Elements oder height des span Elements abhängt.

Vielen Dank für deinen Post,
wobei ich hoffe die kleine Verbesserung sit von Nutzen.

Peace,
Anodyne

verfasst am 12. August 2010 um 14:29

Uuups, habe irgendwo den ""-tag vergessen, sorry.

Anodyne

verfasst am 12. August 2010 um 14:33

Uuups, habe irgendwo den code-tag vergessen, sorry.

Anodyne

verfasst am 26. September 2010 um 12:43

Thanks for the simple tooltip code. It very usefull for me now !

verfasst am 19. Oktober 2010 um 19:39

Thanks for the simple tooltip code. It very

verfasst am 19. Oktober 2010 um 19:40

Uuups, habe irgendwo

verfasst am 19. Oktober 2010 um 19:41

tag vergessen, sorry.

verfasst am 19. Oktober 2010 um 19:42

tooltip code. It very usefull for me

verfasst am 19. Oktober 2010 um 19:44

Thanks for the simple tooltip

verfasst am 19. Oktober 2010 um 19:45

irgendwo den code-tag vergessen, sorry

verfasst am 27. November 2010 um 4:50

Excelent! simple and elegant and easy to style. You rock!

verfasst am 6. Dezember 2010 um 15:43

Very nice indeed, thanks for sharing it!

verfasst am 14. Dezember 2010 um 20:39

Thanks - very nice and simple. Appreciate it

verfasst am 31. Januar 2011 um 20:48

Thanks, five minutes and done... save my life:D

verfasst am 5. Februar 2011 um 15:09

Hey! Just dropping by to let you know my experience with this. I am going to be writing a blog about it as well. I'll comment up the link when I'm done with it and we think of a solution.

Anyhow, a couple things.

This ironically to me works better in Internet Explorer 8 on a Windows 7 Home Premium Operating System.

In Internet Explorer (I dont know if all, but 8 allow atleast) allows you to insert a link inside of the Tooltip. The tooltip obviously will disappear when you move away from the link with your mouse. How do we set a delay time for that to disappear?

verfasst am 10. Februar 2011 um 3:39

Very usefull tutorial man ill use it surely. Thanks :)

verfasst am 23. Februar 2011 um 21:04

Perfect...
Thank you so much...

verfasst am 6. März 2011 um 8:41

Amazing. Thanks a lot.

Nikolay
verfasst am 14. April 2011 um 17:11

Thanks for the awesome guide! Nice and simple, but does the job! A++

verfasst am 28. Juni 2011 um 1:42

wow,, it's very simple

Brent Alton
verfasst am 14. Juli 2011 um 23:09

what is needed to affect the size of the font used in the tooltip?

verfasst am 15. Juli 2011 um 8:10

Hi Brent,
just add: font-size:14px; (or the font-size you want) in the a.tooltip span {} line

Example:
a.tooltip span {display:none; padding:2px 3px; margin-left:8px; width:130px; font-size:14px;}

Seite 4 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