How to set FontAwesome icon width, height and positioning according to its parent's width and height?

3.6k Views Asked by At

I am using FontAwesome icons on my webpage. The height and width of the div, which contains the icon, is based on user input. I want the icon to fit inside div as the div height and width changes. I also want to center the icon inside that div. There is very limited information regarding this on the web.

Can I get/set font-height or font-width via font-size? Any relation between font-size and font-height/width?

1

There are 1 best solutions below

5
On BEST ANSWER

FontAwesome Icons are inside a font, so you set their size with font-size.

You can do that with jQuery like this: $('.icon').css('font-size', 100);