我有一个特殊的情况。如果我在工具提示中放置一个长文本,它会扩展并覆盖工具提示框架,就像这样。
在我将其添加到 .tool-inner
之后
word-break: break-all;
在这种情况下效果很好。
但是,它还是这样打破了正常的句子。
我创建了一个 jsfiddle来说明我做了什么。
最佳答案
使用 word-wrap
css 属性代替 word-break
。
The word-wrap property allows long words to be able to be broken and wrap onto the next line.
/* Latest compiled and minified JavaScript included as External Resource */
$('#hoverme1, #hoverme2').tooltip();
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.tooltip-inner{
color: red;
background-color: black;
word-wrap: break-word;
text-align: left;
white-space: pre-line;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
Tooltip example
<br><br><br><br><br><br><br>
<a href="#" id ="hoverme1" data-toggle="tooltip" title="vocabularyvocabularyvocabularyvocabularyvocabularyvocabulary">long vocabulary</a>
<br>
<a href="#" id ="hoverme2" data-toggle="tooltip" title="This is very long sentence, and this is very important!">Nomal sentence</a>
关于html - Bootstrap 工具提示换行和中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39830175/