Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

my tooltip is cut off by the div container

I have this code to make appear a tooltip when a message box is "hovered". All message boxes are inside a div called chatbox.

$('.box').hover(function(){
     var htmltooltip = '<div id="info" class="shadow">';
     htmltooltip += '<h4>Label info</h4>';
     htmltooltip += '<img src="images/defaultphoto.gif"/>';
     htmltooltip += '</div>';
     $(this).append(htmltooltip).children('#info').hide().fadeIn(400).css('left', -150);
     }, function() {
         $('#info').remove();
     }
   );

This is my css code to the chatbox, box and tooltip called #info

#chatbox {

    position: absolute;
    overflow-y:auto; 
    top:40%;
    left:50%;
    background:#fff;
    height:80%;
    width:550px;
    border:3px solid black;
    }
.box{
    width:90%;
    height:auto;
    margin:5px 20px 0px 0px;
    border:3px solid #918750;
    float:left;
    cursor: pointer;
}
#info{
    position:absolute;
    display:block;
    background:#7F7777;
    width:300px;
    padding-bottom: 0.5em;
    z-index:25;


}

My problem is that the tooltip is cut off by the chatbox div when pass the limits of the chatbox. Here is a jsfiddle: http://jsfiddle.net/Ifalcao/k9Yrc/2/

The overflow rule in the chatbox div must exist, otherwise if I have many message boxes, they will pass the limit of the chatbox. (http://jsfiddle.net/Ifalcao/URBDE) I need the message boxes inside the chatbox but the tooltips of the message boxes outside the chatbox.

Thanks in advance.

like image 706
Falcoa Avatar asked Apr 18 '13 18:04

Falcoa


People also ask

Can a div have a tooltip?

The only thing you have to do is set an attribute on any div called "data-tooltip" and that text will be displayed next to it when you hover over it.

Can we add tooltip in CSS?

One can set a position to that tool tipped text by using CSS, which helps us to define some style and position to our tooltip. Using a tooltip to our WebPages is helps us do more interaction with the user because it gives short information of included elements.

What is a hover tooltip?

Alternatively known as a balloon, help balloon, flyover help, or ScreenTip, a Tooltip is a text description near an object. The tooltip is displayed when the user hovers the mouse cursor over the object.


1 Answers

Remove the overflow-y:auto; rule from the #chatbox div and the tooltip is completely visible.

jsFiddle example

like image 189
j08691 Avatar answered Sep 23 '22 11:09

j08691