Bootstrap Tooltip Not Working with Font Awesome Icon

后端 未结 3 770
清歌不尽
清歌不尽 2021-01-18 02:03

I am using bootstrap tooltip but I cannot seem to get it to work with a font awesome icon.

I can get this to work:

 

        
相关标签:
3条回答
  • 2021-01-18 02:39

    Looks like I just needed to remove the [a] tag surrounding the [i] tag like so:

     <i class="fa fa-info-circle" data-container="body" data-toggle="popover" data-placement="top" title="Other Prep" data-content="Indicates whether or not this product get other prep before shipment" data-original-title=""></i>
    
    0 讨论(0)
  • 2021-01-18 02:45

    According to Bootstrap's documentation. You have to initialize the tooltip & popover functionality.

    $('[data-toggle="tooltip"]').tooltip();
    

    By the way, you don't need the HTML elements AND the Javascript. Just one or the other. I think (not sure fully) your icon may not be working because it renders with nothing between your a tags. You could try putting a &nbsp; in there.

    I was able to get this to work:

    <i class="fa fa-info-circle" data-toggle="tooltip" data-placement="left" title="Tooltip on left"></i>

    0 讨论(0)
  • 2021-01-18 02:53

    You have to set the icon to an inline-block in css:

    i.fa {
       display: inline-block;
    }
    

    Also you should set this option to the popover:

    $(document).ready(function() {
        $("i.fa").popover({'trigger':'hover'});
    });
    

    Fiddle: http://jsfiddle.net/ndzqqhfz/2/

    0 讨论(0)
提交回复
热议问题