Want to make Font Awesome icons clickable

前端 未结 7 2136
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 23:45

So I am new to web development and I am trying to link font awesome icons to my social profiles but am unsure of how to do that. I tried using an a href tag but it made all

相关标签:
7条回答
  • 2020-12-13 00:13
    Please use Like below.
    <a style="cursor: pointer" **(click)="yourFunctionComponent()"** >
    <i class="fa fa-dribbble fa-4x"></i>
     </a>
    

    The above can be used so that the fa icon will be shown and also on the click function you could write your logic.

    0 讨论(0)
  • 2020-12-13 00:20

    If you don't want it to add it to a link, you can just enclose it within a span and that would work.

    <span id='clickableAwesomeFont'><i class="fa fa-behance-square fa-4x"></span>

    in your css, then you can:

    #clickableAwesomeFont {
         cursor: pointer
    }
    

    Then in java script, you can just add a click handler.

    In cases where it's actually not a link, I think this is much cleaner and using a link would be changing its semantics and abusing its meaning.

    0 讨论(0)
  • 2020-12-13 00:20

    I found this worked best for my usecase:

    <i class="btn btn-light fa fa-dribbble fa-4x" href="#"></i>
    <i class="btn btn-light fa fa-behance-square fa-4x" href="#"></i>
    <i class="btn btn-light fa fa-linkedin-square fa-4x" href="#"></i>
    <i class="btn btn-light fa fa-twitter-square fa-4x" href="#"></i>
    <i class="btn btn-light fa fa-facebook-square fa-4x" href="#"></i>
    
    0 讨论(0)
  • 2020-12-13 00:25
                 <a href="#"><i class="fab fa-facebook-square"></i></a> 
                 <a href="#"><i class="fab fa-twitter-square"></i></a> 
                 <a href="#"><i class="fas fa-basketball-ball"></i></a> 
                 <a href="#"><i class="fab fa-google-plus-square"></i></a>
    
    
                  All you have to do is wrap your font-awesome icon link in your HTML 
                                   with an anchor tag.
            Following this format:
                       <a href="Link here"> <font-awesome icon code> </a>
    
    0 讨论(0)
  • 2020-12-13 00:27

    In your css add a class:

    .fa-clickable {
        cursor:pointer;
        outline:none;
    }
    

    Then add the class to the clickable fontawesome icons (also an id so you can differentiate the clicks):

     <i class="fa fa-dribbble fa-4x fa-clickable" id="epd-dribble"></i>
     <i class="fa fa-behance-square fa-4x fa-clickable" id="epd-behance"></i>
     <i class="fa fa-linkedin-square fa-4x fa-clickable" id="epd-linkedin"></i>
     <i class="fa fa-twitter-square fa-4x fa-clickable" id="epd-twitter"></i>
     <i class="fa fa-facebook-square fa-4x fa-clickable" id="epd-facebook"></i>
    

    Then add a handler in your jQuery

    $(document).on("click", "i", function(){
        switch (this.id) {
            case "epd-dribble":
                // do stuff
                break;
            // add additional cases
        }
    });
    
    0 讨论(0)
  • 2020-12-13 00:34

    Using bootstrap with font awesome.

    <a class="btn btn-large btn-primary logout" href="#">
            <i class="fa fa-sign-out" aria-hidden="true">Logout</i>
    </a>
    
    0 讨论(0)
提交回复
热议问题