Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip clipped when overflow is set to auto

Tags:

html

css

My layout has a sidebar on the left, and a content section on the right. Both sides have their own scroll bar and should take up the remaining height of the page.

My problem is that when I set overflow-y: auto so that I can have the scrollbar, the tooltip (from Bootstrap 3) gets clipped if it leaves the containing div.

Here is a fiddle to demonstrate the problem: http://jsfiddle.net/Ljy1nc3v/3/

Setting z-index on the content class and even the tooltip class doesn't work.

Any help would be appreciated, thanks.

like image 440
Rickkwa Avatar asked Feb 12 '15 04:02

Rickkwa


People also ask

What is the difference between overflow scroll and overflow auto?

The difference For that, you need overflow: auto , which lets a browser automatically determine if a scroll bar is needed — or not. So in short: overflow: scroll : Always show a scroll bar. overflow: auto : Show a scroll bar when needed.

How do I make tooltip always show?

Enabling sticky tooltip To make an element display its tooltip permanently, we use its showTooltipOn property. To make tooltip always be shown, set it to "always" .

What does overflow auto do in HTML?

overflow: auto The auto value is similar to scroll , but it adds scrollbars only when necessary: You can use the overflow property when you want to have better control of the layout. The overflow property specifies what happens if content overflows an element's box.

Does overflow hidden prevent scrolling?

To prevent scrolling with this property, just apply the rule overflow: hidden to the body (for the entire page) or a container element. This hides all content beyond the element's border.


1 Answers

The easiest way to fix this is to set a container attribute on your tooltip like this:

$(".tt").tooltip({
    placement: "top",
    title: "<h3>this is a test tooltip</h3>",
    html: true,
    container: 'body'
});

This will append your tooltip to the body element rather than .content div.

like image 105
theseeker Avatar answered Nov 03 '22 02:11

theseeker