As an alternative to styling the .tooltip-inner
in a stylesheet you can add styles directly to the tooltip by modifying the template of the tooltip.
This is probably not a good idea in most cases since you would be applying styles directly to the element, but it's worth noting that this is possible for those few cases where this is the only option or for some reason is the best option.
$(selector).tooltip({
title: "Lorem ipsum ...",
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner" style="max-width: none;"></div></div>',
});
Or, as an attribute:
<span
data-toggle="tooltip"
title="Lorem ipsum ..."
data-template='<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner" style="max-width: none;"></div></div>'
>Some abbreviation</span>
$(function(){
$('[data-toggle="tooltip"]').tooltip();
});
template
option:
Base HTML to use when creating the tooltip.
The tooltip's title
will be injected into the .tooltip-inner
.
.tooltip-arrow
will become the tooltip's arrow.
The outermost wrapper element should have the .tooltip
class.
Defaults to:
'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
As an alternative, you can add your own class to the template and style the custom class.
$(selector).tooltip({
title: "Lorem ipsum ...",
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner my-custom-tooltip"></div></div>',
});
.my-custom-tooltip {
max-width: none;
}