css - jQuery: Tooltip Positioning -
i'm trying figure out how center tooltip under link (so it's not positioned in line link).
[link] [tooltip should appear this] [link] [tooltip should not appear this] i'm trying figure out why tooltip not fading in.
there :
$('a.tooltip').hover(function() { var title = $(this).attr('title'); var offset=$(this).offset(); var width=$(this).outerwidth(); var height=$(this).outerheight(); $content=$('<div class="tooltip">' + title + '</div>').fadein(); $(this).append($content); var middle = offset.left+(width-$content.outerwidth())/2; // middle = math.max(offset.left,offset.left+(width-$content.outerwidth())/2 ); $content.offset({ top: offset.top+height, left: middle }); $('div.tooltip').hover(function() { $(this).fadeout('fast'); }); }, function() { $(this).find('div').fadeout('fast'); }); can make code more readable, idea there ;)
[edit] code changed, text has centered if long. (i misread question)
Comments
Post a Comment