javascript - Make CSS tooltip follow cursor -
i'm creating css based tooltip going have lot of content in tooltip , instead of being in static place wondering there easy way make follow cursor hover on link.
here example of css based tooltip
<div class="couponcode">first link <span class="coupontooltip">content 1</span> </div> .couponcode:hover .coupontooltip { display: block; } .coupontooltip { display: none; background: #c8c8c8; margin-left: 28px; padding: 10px; position: absolute; z-index: 1000; width:200px; height:100px; }
something this
var tooltip = document.queryselectorall('.coupontooltip'); document.addeventlistener('mousemove', fn, false); function fn(e) { (var i=tooltip.length; i--;) { tooltip[i].style.left = e.pagex + 'px'; tooltip[i].style.top = e.pagey + 'px'; } }
Comments
Post a Comment