how to stylize a circle Fontawesome icon background?

六眼飞鱼酱① 提交于 2019-12-10 05:16:44

问题


Is there is a simple way to stylize the Fontawesome icons background properly? I was trying to do it with the icon-remove-sign (which has the particularity to be a circle) icon in order to make appear the cross in white and the circle in red.

The difficulty is that the icon is recognize as a square, so i was trying to make it a circle in order to apply the red background color (but i am wondering if there is not something simpler):

.icon-remove-sign {
    padding: 0;
    border-radius: 25px;
    color: white;
    background-color: red;
}

But it's not enough, we can see the red background at the top of the icon.

How would you do it ?


回答1:


It feels a little hacky, but I managed to get it working here:

http://jsfiddle.net/3FvxA/

display:block and giving it a height and width seems to be the secret.




回答2:


With fontawesome you can use stacked icons like this:

<span class="fa-stack fa-lg">
  <i class="fa fa-camera fa-stack-1x"></i>
  <i class="fa fa-ban fa-stack-2x text-danger"></i>
</span>



回答3:


Assuming that your HTML looks like this:

<div class="social-circle">
  <a class="fa fa-facebook" href="#"></a>
  <a class="fa fa-twitter" href="#"></a>
  <a class="fa fa-pinterest-p" href="#"></a>
</div>

You can do something like:

.social-circle [class*="fa fa-"] {
  width: 25px;
  height: 25px;
  color: white;
  background-color: grey;
  border-radius: 25px;
  display: inline-block;
  line-height: 25px;
  margin: auto 3px;
  font-size: 15px;
  text-align: center;
}
.fa-facebook:hover { 
    background-color: #3B5A9B; 
}
.fa-twitter:hover { 
    background-color: #4FC6F8; 
}
.fa-pinterest-p:hover { 
    background-color: #CA2128; 
}

See the example here : http://jsfiddle.net/k69xj2n8/



来源:https://stackoverflow.com/questions/16949842/how-to-stylize-a-circle-fontawesome-icon-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!