Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap - how to add some more margin between tooltip popup and element

I have not tried anything since I can't understand where space between tooltip and element is made/added from bootstrap, normally tooltip is really near the element who triggers the tooltip event.

I just would like to make the tooltip opening little bit away from the element, to add some more margin from tooltip and element I mean.

I would like to understand how to do this in css if possible and if is possible to make it both for right, left, top, bottom tooltips.

Hope question is clear.

This is how tooltips looks on my app:

enter image description here

and this is what I would like to do and how it should look afterwards:

enter image description here

like image 245
itsme Avatar asked Mar 24 '13 17:03

itsme


People also ask

How do I change the tooltip position in bootstrap?

Positioning of tooltips So to position a tooltip as your requirement just add data-bs-placement=”top/right/left/bottom” attribute to your <a> or <button> tag to change tooltip position.

What are the four options for how a tooltip is triggered?

If a function is given, it will be called with its this reference set to the element that the tooltip is attached to. How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.


2 Answers

This is the default CSS for a tooltip on top :

.tooltip.top {
  padding: 5px 0;
  margin-top: -3px;
}

You can override it in your own CSS :

.tooltip.top {
  margin-top: -10px;
}

Note this code will only work work a tooltip on top, you'll nedd to adapt the CSS for the 3 other orientations :

.tooltip.top    { margin-top: -10px; }
.tooltip.right  { margin-left: 10px; }
.tooltip.bottom { margin-top: 10px;   }
.tooltip.left   { margin-left: -10px; }
like image 198
zessx Avatar answered Sep 28 '22 09:09

zessx


Here is the complete Bootstrap 4 solution

.bs-tooltip-top {
    top: -10px !important;
}

.bs-tooltip-right {
    left: 10px !important;
}

.bs-tooltip-bottom {
    top: 10px !important;
}

.bs-tooltip-left {
    left: -10px !important;
}
like image 30
algorhythm Avatar answered Sep 28 '22 08:09

algorhythm