Ruby On Rails, Design, Simplicity, Web 2.0, Ajax, Mac and Tons of Pizza.

Jan 28

Creating bubble tooltips.....

Posted by Annalisa Afeltra in Design - Web 2.0 - comments are closed digg this add to delicious

While trying to look for tips and tricks to make my web applications more interesting I came across an interesting article written by Alessandro Fulciniti . He uses javascript, css and a simple image to create bubble tooltips on web applications.

How it works:

Firstly the javascript, css and image must be saved in the same directory as the page.

It simply uses an image that is called from the css file, therefore this can be modified with an image that you prefer.

The following must be copied into the head section of the page to reference the javascript file and the javascript file BubbleTooltips must be copied into the same directory.


<script type="text/javascript" src="BubbleTooltips.js"></script>
<script type="text/javascript">
window.onload=function(){enableTooltips()};
</script>

If you require some links to be without the bubble tooltip, the following script should rather be used as it requires an id to be passed to it that specifies which link requires the bubble tooltip to appear.


<script type="text/javascript" src="BubbleTooltips.js"></script>
<script type="text/javascript">
window.onload=function(){enableTooltips("content")};
</script>

Two different ways can be utilized to make use the bubble tooltip, either by using the code below

<span class="tooltip">
<span class="top">title of the link</span>
<b class="bottom">url of the link, max 30 chars</b>
</span>

or a normal html link :

<a href="http://whodo.es">Who Does</a> 

Bear in mind that depending on the script used in the head, you need to use the a div with an id for example:

 <div id ="content"></div>

to specify for which links the bubble tooltip needs to appear.

Lastly the following css code creates the image, for example bubble, which is displayed in the background of the bubble tooltip.

.tooltip{
width: 200px; color:#000;
font:lighter 11px/1.3 Arial,sans-serif;
text-decoration:none;text-align:center}

.tooltip span.top{padding: 30px 8px 0;
    background: url(bt.gif) no-repeat top}

.tooltip b.bottom{padding:3px 8px 15px;color: #548912;
    background: url(bt.gif) no-repeat bottom}

Now you are ready to start creating your own bubble tooltip application…. so start bubbling!!

Comments

  • Paul Davis

    Posted on March 02

    Hi Annalisa, I've made a variation on the bubble tooltip here: http://willcode4beer.com/tips.jsp?set=bubbleTooltips With this model, you don't have to do anything special to the html (style classes etc). Instead, you just define which element types should receive the tooltip. The text of the tooltip comes right from the title attribute. Hope you find it useful
  • nicolash

    Posted on March 17

    I miss some kind of delay in the script. This can be quite annoying if you follow your reading with the mouse. I think it would be much better (and easily amended) if you copy the functionality of title-attributes that require some hovering-time before they appear.
  • Annalisa Afeltra

    Posted on March 18

    Hi Nicolash, thanks very much for your advice. I will try and do it in the future.
  • Annalisa

    Posted on March 19

    Hi Paul, Thanks very much for your advice, it is very useful and will definitely make use of it.

Post a comment

Categories:

Tags:

Powered by Mephisto, Valid XHTML 1.1, Valid CSS - Supported by Wave Factory