Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add border around font-awesome (v5) icon

This question has been asked before in this post. But I don't think its still working with the new font-awesome because they use svg and path elements.

This question is about having a border around the icon, instead of having it around the outer circle.


Some of the solutions found that I tried, but did not work:

.fa-female, .fa-music{
  color: #BBB;
}

.fa-female{
  -webkit-text-fill-color: #BBB;
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke:4px #00FF00;
}

.fa-music{
  text-shadow: 0px 0px 3px #00FF00;
}
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
 
<!-- Female Icon --> 
<span class="fa-layers fa-fw fa-8x" style="color: rgb(190, 53, 48)">
  <i class="fas fa-circle"></i>
  <i class="fas fa-female fa-inverse" data-fa-transform="shrink-6 fa-border"></i>
</span>

<!-- Music Icon --> 
<span class="fa-layers fa-fw fa-8x" style="color: rgb(190, 53, 48)">
   <i class="fas fa-circle"></i>
   <i class="fas fa-music fa-inverse" data-fa-transform="shrink-8 fa-border"></i>
</span>

<i class="fas fa-music fa-inverse fa-5x" style="color: black;"></i>

Edit: Solution that worked in a codesnippet
Solution by reiallenramos

.fa-music g g path {
  stroke: black;
  stroke-width: 10;
}
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

<!-- Music Icon --> 
<span class="fa-layers fa-fw fa-8x" style="color: rgb(190, 53, 48)">
   <i class="fas fa-circle"></i>
   <i class="fas fa-music fa-inverse" data-fa-transform="shrink-8 fa-border"></i>
</span>
like image 780
Jeremy Avatar asked Feb 02 '18 12:02

Jeremy


People also ask

How do you put a border on font awesome icons?

To increase fa-border-all font awesome icon size, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes along with icon class fa-border-all.


Video Answer


2 Answers

I had to dissect the internals of font-awesome.

.fa-music g g path {
  stroke: black;
  stroke-width: 10;
}
like image 62
reiallenramos Avatar answered Oct 19 '22 01:10

reiallenramos


The new FontAwesome way would be layers: https://fontawesome.com/how-to-use/svg-with-js#layering

<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
 
<span class="fa-layers fa-fw fa-5x">
   <i class="fas fa-circle" style="color:black"></i>
   <i class="fas fa-circle" data-fa-transform="shrink-3" style="color:Tomato"></i>
   <i class="fa-inverse fas fa-female" data-fa-transform="shrink-6"></i>
</span>
like image 6
Ron van der Heijden Avatar answered Oct 19 '22 02:10

Ron van der Heijden