Bootstrip 4 tooltip position: auto right

99 views Asked by At

I want my tooltip to be on the right of the elements on desktop, because it fits my design best. However this however raises an issue when working on a smaller screen. The bootstrap 3 documentation says it supports auto right placement, which should prefer the tooltip on the right and if that is impractical it will auto pick a side. I am using bootstrap 4 and I tried using that option, but it wont work.

Is there any way to achieve the same result in bootstrap 4?

1

There are 1 answers

0
isherwood On BEST ANSWER

If using 'right auto' doesn't work you could use a function to return the value based on screen size:

placement: function() {
    return $(window).width() > 767 ? 'right' : 'auto';
}

This isn't a responsive solution as it doesn't update if the window size changes, but it should do for most cases. If you want fully responsive behavior you'll need re-initialize tooltips on size change.