[ CSS ]
#bubble_tooltip{ width:147px; position:absolute; display:none; } #bubble_tooltip .bubble_top{ background-image: url('../images/bubble_top.gif'); background-repeat:no-repeat; height:16px; } #bubble_tooltip .bubble_middle{ background-image: url('../images/bubble_middle.gif'); background-repeat:repeat-y; background-position:bottom left; padding-left:7px; padding-right:7px; } #bubble_tooltip .bubble_middle span{ position:relative; top:-8px; font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif; font-size:11px; } #bubble_tooltip .bubble_bottom{ background-image: url('../images/bubble_bottom.gif'); background-repeat:no-repeat; background-repeat:no-repeat; height:44px; position:relative; top:-6px; }
[ JS ]
function showToolTip(e,text){ if(document.all)e = event; var obj = document.getElementById('bubble_tooltip'); var obj2 = document.getElementById('bubble_tooltip_content'); obj2.innerHTML = text; obj.style.display = 'block'; var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; var leftPos = e.clientX - 100; if(leftPos<0)leftPos = 0; obj.style.left = leftPos + 'px'; obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px'; }
function hideToolTip() { document.getElementById('bubble_tooltip').style.display = 'none'; }
[ HTML ]
<html> <head> <title>Balloon tooltip</title> <style type="text/css"> body{ background-image:url('../../images/heading3.gif'); background-repeat:no-repeat; padding-top:85px; font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif; font-size:0.9em; line-height:130%;
} a{ color: #D60808; text-decoration:none; } a:hover{ border-bottom:1px dotted #317082; color: #307082; } </style> <link rel="stylesheet" href="css/bubble-tooltip.css" media="screen"> <script type="text/javascript" src="js/bubble-tooltip.js"></script> </head> <body> <div id="bubble_tooltip"> <div class="bubble_top"><span></span></div> <div class="bubble_middle"><span id="bubble_tooltip_content">Content is comming here as you probably can see.Content is comming here as you probably can see.</span></div> <div class="bubble_bottom"></div> </div> <h1>DHTML Balloon tooltip</h1> <p>This demo demonstrates how the balloon tooltip works. Roll your mouse over the red links in the text below.</p> <p><a href="#" onmouseover="showToolTip(event,'This is a simple, simple test');return false" onmouseout="hideToolTip()">Roll over me</a> to see the tooltip in action.</p> <p>And here's some more content <a href="#" onmouseover="showToolTip(event,'This is the content of the tooltip. This is the content of the tooltip.');return false" onmouseout="hideToolTip()">Roll over me</a> </p> <p>This is the last piece of the content on this web page</p> </body> </html>
|