Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can font-awesome icon background be transparent?

I am using a font awesome "x" icon - but it has a white background - can font-awesome backgrounds be transparent?

The reason is, I want to display it over an image. What option do I need to do this?

Current Code is:

 <i class="fa fa-times fa- m-n"></i>
like image 521
Paul Preibisch Avatar asked May 21 '14 08:05

Paul Preibisch


People also ask

How can I make my icon background transparent?

Start by opening the icon in the Icon Editor by clicking on the Edit icon button. Select the element that you want to make transparent. Then, click the colour picker and click on the little box with a red cross. Click OK.

Can .ICO have transparent background?

You are correct, ico files can be transparent, but when you use Irfanview to convert your transparent gif to an ico file, it will give it a background. So, you need to use an icon editor to go remove those background bits.

How do you change the background color of font awesome icons?

UPDATE: As xavier pointed out below, font-awesome has Stacked Icons which will let you put a circle behind an icon without using a hack. Essentially, you stack whichever icon you want on top of their fa-circle icon. You can then style the circle independently from the icon and change it to whatever color you'd like.

How do I use Font Awesome icons as my background image?

Here is a simple quick way to use icons from Font Awesome as a “background-image” using CSS. You need to get the code of the symbol of Font Awesome. The easiest way is to use your browser inspector on the the icon you want to use and copy the code, in my example it's the little star icon using the code “\f005”.


1 Answers

Yes, font awesome uses the ::before psuedo for its icons, so simply do, e.g.:

Demo Fiddle

i::before{
    background:transparent;
}

That said, you will likely want to use more specificity than simply i, e.g.:

i[class*=fa-times]::before{
   background:transparent;
}
like image 110
SW4 Avatar answered Sep 30 '22 09:09

SW4