I created a tooltip using Twitter Bootstrap.
The tooltip is displaying with three lines. However, I would like to display the tooltip with only one line.
How
Just override bootstrap.css
The default value in BS2 is max-width:200px; So you can increase it with whatever fits your needs.
.tooltip-inner {
max-width: 350px;
/* If max-width does not work, try using width instead */
width: 350px;
}
On Bootstrap 4, and if you don't want to change all tooltips width, you can use specific template for the tooltip you want :
<a href="/link" class="btn btn-info"
data-toggle="tooltip"
data-placement="bottom"
data-template="<div class='tooltip' role='tooltip'><div class='arrow'></div><div class='tooltip-inner' style='max-width: 400px;'></div></div>"
title="This is a long message displayed on 400px width tooltip !"
>
My button label
</a>
With Bootstrap 4 I use
.tooltip-inner {
margin-left: 50%;
max-width: 50%;
width: 50%;
min-width: 300px;
}
in bootstrap 3.0.3 you can do it by modifying the popover class
.popover {
min-width: 200px;
max-width: 400px;
}
after some experimenting, this worked best for me:
.tooltip-inner {
max-width: 350px; /* set this to your maximum fitting width */
width: inherit; /* will take up least amount of space */
}
Define the max-width with "important!" and use data-container="body"
CSS file
.tooltip-inner {
max-width: 500px !important;
}
HTML tag
<a data-container="body" title="Looooooooooooooooooooooooooooooooooooooong Message" href="#" class="tooltiplink" data-toggle="tooltip" data-placement="bottom" data-html="true"><i class="glyphicon glyphicon-info-sign"></i></a>
JS script
$('.tooltiplink').tooltip();