JSFiddle - React, Tailwind, and code Playground
HTML
<div class="sideMore sidebar_p_crop">
<a class="imgsidder tip_trigger" href="#">
<img src="http://www.google.com/logos/2011/valentines11-res.jpg">
<span class="tip">This is the tip tool :-)</span>
</a>
</div>
<div class="sideMore sidebar_p_crop">
<a class="imgsidder tip_trigger" href="#">
<img src="http://www.google.com/logos/2011/valentines11-res.jpg">
<span class="tip">This is the tip tool # 2 :-)</span>
</a>
</div>
CSS
.tip {
color: #fff;
background:#1d1d1d;
padding:10px;
position:absolute;
z-index:1000;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.tip_trigger .tip { display:none; }
JavaScript
$(function() {
$('.tip_trigger').each(function() {
var tip = $(this).find('.tip');
$(this).hover(
function() { tip.appendTo('body'); },
function() { tip.appendTo(this); }
).mousemove(function(e) {
var x = e.pageX + 20,
y = e.pageY + 20,
w = tip.width(),
h = tip.height(),
dx = $(window).width() - (x + w),
dy = $(window).height() - (y + h);
if ( dx < 20 ) x = e.pageX - w - 20;
if ( dy < 20 ) y = e.pageY - h - 20;
tip.css({ left: x, top: y });
});
});
});