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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:57:43  来源:igfitidea点击:

Add line break to tooltip in Bootstrap 3

jquerytwitter-bootstraptwitter-bootstrap-3

提问by Pierce McGeough

I am using Bootstrap 3 and added a tooltip to my div. I've tried using < br > \n and &#013; 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 &#013; - Item 2 &#013;"

CSS

CSS

.ui-tooltip {
    /* tooltip container box */
    white-space: pre-line;
}

.ui-tooltip-content {
    /* tooltip content */
    white-space: pre-line;
}