Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing font-awesome size in css. How do you do it?

Tags:

font-awesome

I tried changing font awesome sizes using font-size but it doesn't work because of this css:

font-size: inherit

Is there a way to override this? I am trying to have font-awesome to be two different sizes when mobile or screen and I want to affect the font-size using css and not different sized font-awesome tags. What can I do?

like image 663
Jwan622 Avatar asked Sep 06 '15 17:09

Jwan622


People also ask

How do I change the size of font awesome icons in CSS?

To increase icon sizes relative to their container, use the fa-lg (33% increase), fa-2x , fa-3x , fa-4x , or fa-5x classes. If your icons are getting chopped off on top and bottom, make sure you have sufficient line-height.

How do I make Font Awesome bigger?

font-awesome icons are texts. So use font-size to increase the size of font-awesome icons. Show activity on this post. To increase icon sizes relative to their container, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes.

How do you change the font-size in CSS font?

To change the size of your text with inline CSS, you have to do it with the style attribute. You type in the font-size property, and then assign it a value.


4 Answers

Usually font-awesome icons get the size of the element they are used within (i.e. inherit). For example:

HTML

<p><i class='fa fa-pencil'></i> Some text here.</p>

CSS

p{
   font-size: 16px;
}

Your icon will be of 16px size in that case. However you can resize icons separately. First of all, make sure that your css file goes after font-awesome.css in <head> block for it to be in priopity or use !important.

1) You can rewrite 'fa' class styles from font-awesome.css in your own css file:

.fa{
    font-size: 3em !important; /*size whatever you like*/
}

2) Or give icon some other class and style it:

.newclass-for-i{
    font-size: 3em;
}

To set different styles for mobile and screen use css media queries:

@media (max-width:desired width){
    your styles
}
like image 177
chem1st Avatar answered Oct 13 '22 13:10

chem1st


You can update the font-size of a FA icon using the before pseudo-element. No need for extra wrapper elements or rewriting classes.

i.fa::before{
    font-size: 40px;
}
like image 44
Bilow Avatar answered Oct 13 '22 14:10

Bilow


you can use an extra class or id e.g.

<i class="fa fa-search large_icon"></i>

and the style it using css

.large_icon{
   font-size:24pt;
}
like image 43
Waqas Ahmed Avatar answered Oct 13 '22 12:10

Waqas Ahmed


font awesome has classes for size such as fa-2x, fa-3x etc...

For example:

<i class="fas fa-user fa-2x">
like image 2
Gary Jorgenson Avatar answered Oct 13 '22 14:10

Gary Jorgenson