I have some hidden speech bubbles that appear when you hover over links like this demo:
http://jsfiddle.net/mmorrell2014/e4q7K/
HTML:
<div id="container"><a href="#" class="hoverbubble">Hover over me!<span>Hidden message here.</span></a></div>
CSS:
#container {
background-color: #FF0;
margin: 100px;
float: left;
height: 200px;
width: 200px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
a.hoverbubble {
position: relative;
text-decoration: none;
}
a.hoverbubble span {display: none;
}
a.hoverbubble:hover span {
display: block;
position: absolute;
padding: .5em;
content: attr(title);
min-width: px;
text-align: center;
width: auto;
height: auto;
white-space: nowrap;
top: -40px;
background: rgba(0,0,0,.8);
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
color: #fff;
font-size: 0.86em;
font-family: Arial, Helvetica, sans-serif;
}
a.hoverbubble:hover span:after {
position: absolute;
display: block;
content: "";
border-color: rgba(0,0,0,.8) transparent transparent transparent;
border-style: solid;
border-width: 10px;
height: 0;
width: 0;
position: absolute;
bottom: -20px;
left: 1em;
}
I was wondering if it is possible to make this tooltip appear when you hover over an image instead of a link?
If you want a very simple solution, change your code like below.
<div id="container"><a href="#" class="hoverbubble"><img src="sample.gif" border="0" /><span>Hidden message here.</span></a></div>
If you don't want to use anchor tag itself then check the below jsfiddle, I have updated your code.