jQuery 在 Bootstrap 3 的工具提示中添加换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19001766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add line break to tooltip in Bootstrap 3
提问by Pierce McGeough
I am using Bootstrap 3 and added a tooltip to my div. I've tried using < br > \n and 
 to create the new line. Would it be a problem with the Bootstrap stopping me?
我正在使用 Bootstrap 3 并在我的 div 中添加了一个工具提示。我试过使用 < br > \n 和 创建新行。Bootstrap 会阻止我吗?
<div class="content show-tooltip" data-placement="top"
data-original-title="1st line of text <br> 2nd line of text">
回答by Zim
You need to add data-html="true"
to the markup..
您需要添加data-html="true"
到标记..
<div class="content show-tooltip" data-html="true" data-placement="top"
title="1st line of text <br> 2nd line of text">
Working demo: http://www.bootply.com/83099
工作演示:http: //www.bootply.com/83099
回答by Thalles Noce
In the Title use this code to break the line:
在标题中使用此代码来断行:
HTML
HTML
...title="- Item 1 
 - Item 2 
"
CSS
CSS
.ui-tooltip {
/* tooltip container box */
white-space: pre-line;
}
.ui-tooltip-content {
/* tooltip content */
white-space: pre-line;
}