在Tippy中,我想在工具提示中显示标签。为此,
我尝试过:
<i style="font-size:20px;" class="fa fa-info tippy" data-tippy-content="You do not need to add <style>....</style> tags."></i>
OR
<i style="font-size:20px;" class="fa fa-info tippy" data-tippy-content="You do not need to add <style>...</style> tags."></i>
但是它们两个都不能正确显示工具提示的内容。我想要这样(此图像在Photoshop中创建):
编辑:但是它们都显示如下:
答案 0 :(得分:2)
您可以在.tippy
类中添加allowHTML: false
选项,以使HTML呈现为文本,而不是实际呈现标记:
tippy(".fa-info.allowHTML")
tippy(".fa-info", {
allowHTML: false
})
<script src="https://unpkg.com/popper.js@1/dist/umd/popper.min.js"></script>
<script src="https://unpkg.com/tippy.js@4"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<i style="font-size:20px;" class="fa fa-info tippy " data-tippy-content="You do not need to add <style>....</style> tags."></i>
<br />
<br />
<i style="font-size:20px;" class="fa fa-info tippy allowHTML" data-tippy-content=" Click <b>Send</b> button for sending..."></i>
答案 1 :(得分:1)
如果在转义的字符之间留出空格,则似乎可以显示预期的结果。
<script src="https://unpkg.com/popper.js@1/dist/umd/popper.min.js"></script>
<script src="https://unpkg.com/tippy.js@4"></script>
<button data-tippy-content="You do not need to add < style >....< /style > tags.">Text</button>
<script>
tippy('button')
</script>