jqueryfont-sizefont-awesome-4

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


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?


Solution

  • 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);