簡體   English   中英

如何使用內部不同顏色的文本創建 Bootstrap 5 工具提示?

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

似乎在自定義 HTML 工具提示中添加雙引號字符"會破壞工具提示本身,使瀏覽器認為工具提示標題已經結束並將工具提示標題的一部分解析為外部 HTML。

這是一個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>">

@poo 的答案對我不起作用,在使用課程時它給了我你正在尋找的答案。

這是一個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