I have created a tooltip using bootstrap for dropdown control. It shows the tooltip.
But since this control is binded inside class="col-sm-4"
tooltip text is broken to new lines. But I expect to show this in a single line. Any idea to make this?
<div class="col-sm-4">
<select class="form-control" id="ddlSchoolAttended" data-toggle="tooltip" data-placement="right" title="Some tooltip 2!Some tooltip 2!Some ">
<option value="08">08 -Year 8 or below</option>
<option value="09">09 -Year 9 or equivalent</option>
<option value="10">10 -Completed Year 10</option>
<option value="11">11 -Completed Year 11</option>
<option value="12">12 -Completed Year 12</option>
<option selected="selected" value="">--Not Specified--</option>
</select><br/>
</div>
Yes - ToolTips obey "\r\n" characters and start on a new line.
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.
HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .
.tooltip-inner {
white-space:nowrap;
max-width:none;
}
Add this to your CSS after the Bootstrap CSS. However, using the hover on a right, even right auto, will be off screen on smaller viewports, but since smaller viewports are generally touch, hovers may make this require a double tap to work. I usually use a script to detect touch for IOS, Android, and Windows mobile and then only use the tooltip on no-touch devices, so this doesn't interfere with user taps.
Although Christina's answer works, it only patches the problem and may create other problems elswhere. In the bootstrap documentation it is mentioned this:
Tooltips in button groups, input groups, and tables require special setting When using tooltips on elements within a .btn-group or an .input-group, or on table-related elements, you'll have to specify the option
container: 'body'
to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip is triggered).see Bootstrap docs
so all you need to do is add container: 'body'
like so:
$(function () {
$('[data-toggle="tooltip"]').tooltip({container: 'body'})}
);
hope this helps
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