如何在HTML工具提示中添加换行符?
我尝试在工具提示中使用<br/>和\n,如下所示:
<a href="#" title="Some long text <br/> Second line text \n Third line text">Hover me</a>
然而,这是无用的,我可以在工具提示中看到文字<br/>和\n。任何建议都会很有帮助。
如何在HTML工具提示中添加换行符?
我尝试在工具提示中使用<br/>和\n,如下所示:
<a href="#" title="Some long text <br/> Second line text \n Third line text">Hover me</a>
然而,这是无用的,我可以在工具提示中看到文字<br/>和\n。任何建议都会很有帮助。
当前回答
只需使用实体代码
用于标题属性中的换行符。
其他回答
这个CSS是我在编辑器中与换行一起工作的最终结果:
.tooltip-inner {
white-space: pre-wrap;
}
在这里找到: 如何使Twitter引导工具提示有多行?
& # 013;结合样式留白:行前;为我工作。
\n
在造型上
.tooltip-inner {
white-space: pre-line;
}
为我工作。
使用.html()而不是.text()对我来说很有效。例如
.html("This is a first line." + "<br/>" + "This is a second line.")
您可以使用引导工具提示,不要忘记将html选项设置为true。
<div id="tool"> tooltip</div>
$('#tool').tooltip({
title: 'line one' +'<br />'+ 'line two',
html: true
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>