CSS Sets the position of an element to the location of the mouse

I use CSS3 to display a tooltip on hover:

.tooltip { position:absolute; /* don't push other text out of the way */ visibility:hidden; } .f:hover .tooltip { visibility:visible; } 

This is fine, but if a piece of text is large, it may seem a bit odd to point it in one place and show a tooltip in another. Is there a way, without using JavasScript (I know this is a cakewalk with JavaScript), so that the element appears near the mouse, where it first hung the text? Something like (conceptual example):

 .f:hover:before .tooltip { top:mouse-y; right:mouse-x; } 
+4
source share
1 answer

Without javascript, there is no way. CSS will not allow you to style elements against the mouse cursor.

+5
source

All Articles