Make Font Awesome icons in a circle?

前端 未结 14 1109
情书的邮戳
情书的邮戳 2020-12-02 04:38

I am using font awesome on some project but I have some things that I want to do with font awesome icons, I can easily call an icon like this:



        
相关标签:
14条回答
  • 2020-12-02 05:33

    This is the approach you don't need to use padding, just set the height and width for the a and let the flex handle with margin: 0 auto.

    .social-links a{
      text-align:center;
    	float: left;
    	width: 36px;
    	height: 36px;
    	border: 2px solid #909090;
    	border-radius: 100%;
    	margin-right: 7px; /*space between*/
        display: flex;
        align-items: flex-start;
        transition: all 0.4s;
        -webkit-transition: all 0.4s;
    } 
    .social-links a i{
    	font-size: 20px;
        align-self:center;
    	color: #909090;
        transition: all 0.4s;
        -webkit-transition: all 0.4s;
        margin: 0 auto;
    }
    .social-links a i::before{
      display:inline-block;
      text-decoration:none;
    }
    .social-links a:hover{
      background: rgba(0,0,0,0.2);
    }
    .social-links a:hover i{
      color:#fff;
    }
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
    
    <div class="social-links">
        <a href="#"><i class="fa fa-facebook fa-lg"></i></a>
        <a href="#"><i class="fa fa-twitter fa-lg"></i></a>
        <a href="#"><i class="fa fa-google-plus fa-lg"></i></a>
        <a href="#"><i class="fa fa-pinterest fa-lg"></i></a>
    </div>

    0 讨论(0)
  • 2020-12-02 05:34

    This is the best and most precise solution I've found so far.

    CSS:

    .social .fa {
          margin-right: 1rem;
          border: 2px #fff solid;
          border-radius: 50%;
          height: 20px;
          width: 20px;
          line-height: 20px;
          text-align: center;
          padding: 0.5rem;
        }
    
    0 讨论(0)
  • 2020-12-02 05:36

    i.fa {
      display: inline-block;
      border-radius: 60px;
      box-shadow: 0px 0px 2px #888;
      padding: 0.5em 0.6em;
    
    }
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
    <i class="fa fa-wrench"></i>


    JsFiddle of old answer: http://fiddle.jshell.net/4LqeN/

    0 讨论(0)
  • 2020-12-02 05:36

    You can also do this. I wanted to add a circle around my icomoon icons. Here is the code.

    span {
    font-size: 54px;
    border-radius: 50%;
    border: 10px solid rgb(205, 209, 215);
    padding: 30px;
    }
    
    0 讨论(0)
  • 2020-12-02 05:38

    The below example didnt quite work for me,this is the version that i made work!

    HTML:

    <div class="social-links">
        <a href="#"><i class="fa fa-facebook fa-lg"></i></a>
        <a href="#"><i class="fa fa-twitter fa-lg"></i></a>
        <a href="#"><i class="fa fa-google-plus fa-lg"></i></a>
        <a href="#"><i class="fa fa-pinterest fa-lg"></i></a>
    </div>
    

    CSS:

    .social-links {
        text-align:center;
    }
    
    .social-links a{
        display: inline-block;
        width:50px;
        height: 50px;
        border: 2px solid #909090;
        border-radius: 50px;
        margin-right: 15px;
    
    }
    .social-links a i{
        padding: 18px 11px;
        font-size: 20px;
        color: #909090;
    }
    
    0 讨论(0)
  • 2020-12-02 05:40

    Font Awesome icons are inserted as a :before. Therefore you can style either your i or a like so:

    .i {
       background: #fff;
       border-radius: 50%;
       display: inline-block;
       height: 20px;   
       width: 20px;
    }
    
    <a href="#"><i class="fa fa-facebook fa-lg"></i></a>
    
    0 讨论(0)
提交回复
热议问题