Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltips on an image

I have an image and on it are logos (it's a map), I want to have a little box popup with information about that logo's location when the user moves their mouse over said logo.

Can I do this without using a javascript framework and if so, are there any small libraries/scripts that will let me do such a thing?

like image 998
Teifion Avatar asked Aug 24 '08 16:08

Teifion


4 Answers

Yes, you can do this without Javascript. Use an HTML image map, with title attributes, like this:

<img usemap="#logo" src="http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png">
<map name="logo">
<area shape="rect" href="" coords="52,42,121,65" title="Stack">
<area shape="rect" href="" coords="122,42,245,65" title="Overflow">
</map>

The Stack Overflow logo refers to the image map, which defines a rectangle for each of the two words using an area tag. Each area tag's title element specifies the text that browsers generally show as a tooltip. The shape attribute can also specify a circle or polygon.

like image 91
Peter Hilton Avatar answered Sep 19 '22 05:09

Peter Hilton


The title attribute is the simplest solution and guaranteed to work, and degrade gracefully for useragents that don't support it correctly.

like image 31
travis Avatar answered Sep 22 '22 05:09

travis


A single image alone doesn't give the browser the semantic information on the logos within. You could use an image map to supply the coordinates. To achieve tooltips, just apply a title attribute to each link. For more sophisticated tooltips (such as with styling, multiple lines, etc.), you'll need something non-standard, such as UniTip.

like image 25
Sören Kuklau Avatar answered Sep 20 '22 05:09

Sören Kuklau


MooTools has a nifty script for this. See MooTools Tips. Lightweight on the HTML as well.

Here's a demo of the 1.11 version.

like image 26
Ross Avatar answered Sep 21 '22 05:09

Ross