Here's my code:
HTML:
<div class="cart">
<a data-toggle="tooltip" title="add to cart">
<i class="fa fa-cart"></i>
</a>
</div>
JQuery:
$('a[data-toggle="tooltip"]').tooltip({
animated : 'fade',
placement : 'bottom'
});
CSS:
.cart{
overflow:hidden;
padding:10px 3px;
}
When I hover the cart icon, the tooltip shows, but it is not at the top of the cart box.
How can I fix this?
To create a tooltip, add the data-toggle="tooltip" attribute to an element. Note: Tooltips must be initialized with jQuery: select the specified element and call the tooltip() method.
How to position the tooltip - auto | top | bottom | left | right. When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second.
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
You can use container
attribute so tooltip itself will be placed in parent container or event body element and it won't break even with overflow hidden because it will be positioned absolutely.
$('a[data-toggle="tooltip"]').tooltip({
animated : 'fade',
placement : 'bottom',
container: 'body'
});
You can also simply add data-container="body" to the tooltipped element. E.g. <button type="submit" title="Add Record to Book Bag" data-toggle="tooltip" data-container="body" aria-role="button"> ... </button>
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