简体   繁体   English

如何使用内部不同颜色的文本创建 Bootstrap 5 工具提示?

[英]How do I Create Bootstrap 5 Tooltip With Text of Different Color Inside?

It seems that adding the double quote char " to the custom HTML tooltip will break the tooltip itself, making the browser think that the tooltip title is over and parsing a chunk of the tooltip title as external HTML.似乎在自定义 HTML 工具提示中添加双引号字符"会破坏工具提示本身,使浏览器认为工具提示标题已经结束并将工具提示标题的一部分解析为外部 HTML。

Here's a jsfiddle .这是一个jsfiddle

将您的代码从双引号更新为标题属性中的单引号。

<button type="button" class="btn btn-danger" data-bs-toggle="tooltip" data-bs-html="true" title="<span style=' color : red'>Red Text</span><br><span style='color : green'>Green Text</span>">

The answer of @poo is not working for me, when using classes it gave me the answer you are searching for. @poo 的答案对我不起作用,在使用课程时它给了我你正在寻找的答案。

Here is a https://jsfiddle.net/p5bzmqd1/这是一个https://jsfiddle.net/p5bzmqd1/

<button type="button" class="btn btn-danger" data-bs-toggle="tooltip" data-bs-html="true" title="<span class=redToolTip>Red Text</span><br><span class=greenToolTip>Green Text</span>">
  I'm a problematic tooltip
</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM