Show caption as tooltip on mouseover
-
this is a bit more complex than you think and I do not have the time to code it for you.
But I can try to show you the right direction.
On each page you have many images with many captions. So if you would make that the captions are following your mouse – they will ALL follow your mouse.
So you need to use something like
jQuery(this)
when you hover an image. Then the function only is active for this specific box.Then make the coordinates of the box just follow the coordinates of your mouse. This has nothing to do with tooltip.
It will just look like it.Have a look here:
https://stackoverflow.com/questions/306583/how-to-get-the-children-of-the-this-selector
https://stackoverflow.com/questions/3385936/jquery-follow-the-cursor-with-a-divYou will need to experiment a little. But it is totally possible.
Good luck!
Marius
-
@mariusjopen Okay I'll give that a try, thanks!!
-
Figured it out! Heres the script if anyone needs it:
<script>
jQuery(document).bind('mousemove', function(e){
jQuery(".caption").offset({left: e.pageX, top: e.pageY});
});
</script>and custom CSS:
.img:hover .caption {
display: block;
position: absolute;
}.caption {
display: none;
font-family: Slantbeta5;
font-size: 30px;
color: #17242c;
position: absolute;
z-index: 1000;
} -
-
Very curious to know if this could work for project titles on project thumbnails?
Something like this:
http://jsfiddle.net/ANKwQ/3265/ -
Dear @extra-vitamins
sure. It can work for every div box.
One thing you need to consider is that it will trigger ALL the project titles. So you need to run a loop and catch each project title ID.Best!
Marius
-
@extra-vitamins @mariusjopen
Hey,
just noticed that lightbox zoom doesn't work on safari when script added. Firefox is working ok.Any ideas how to get this working on safari also?!
Best,
Seppo -
Dear @extra-vitamins
Can you post a link to our website?
Then we can have a look and inspect that.Marius
-
@extra-vitamins thanks, It works! But the I can't figure how to "offset" the caption by say x: 20px and y: 20px, since it's origin is 0,0 on the mouse pointer.
I could change the mouse icon, but that would be weird, or add spaces before the caption text, but then again the placement feels off.
Relative position with left/right, top/bottom values doesn't work in the img:hover caption (…) CSS.
Any ideas?
(sorry, I'm a real noob)
-
jQuery(".caption").offset({left: e.pageX + 10, top: e.pageY + 10});
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it