简体   繁体   中英

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.

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

jsFiddle example

将tooltip css添加为overflow: visible;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM