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.
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.
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.
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.
Remove the overflow-y:auto;
rule from the #chatbox
div and the tooltip is completely visible.
jsFiddle example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With