Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a stacked Font Awesome icon have the same width as a fixed width non stacked one?

http://jsfiddle.net/cirosantilli/aZ9g4/3/

The stacked "GitHub Issue" icon is twice as large as the other fixed width non stacked ones, and makes my nav look bad.

Is there a way within the library to make it be the same size without hacking low level CSS properties?

If only there was a fa-stack-half...

If not, what is the best workaround?


People also ask

How do I make font awesome icons the same size?

If you prefer to work with icons that have a consistent width, adding fa-fw will render each icon using the same width.

How do I stack font awesome icons?

To stack multiple icons, use the fa-stack class on the parent HTML element of the 2 icons you want to stack. Then add the fa-stack-1x class for the regularly sized icon and add the fa-stack-2x class for the larger icon. fa-inverse can be added to the icon with the fa-stack-1x to help with a knock-out looking effect.

What is fa-FW in font awesome?

The fa-fw class is used to set icons at a fixed width. This class is useful when different icon widths throw off alignment.


2 Answers

Looking at the examples for stacked icons, you can do this by modifying the font-size on the span:

Just add a rule like:

.fa-sm {
    font-size:0.63em;
}

With Markup:

<span class="fa-stack fa-sm">
  <i class="fa fa-exclamation fa-stack-1x"></i>
  <i class="fa fa-circle-o fa-stack-2x text-danger"></i>
</span>Github Issue 

Fiddle: http://jsfiddle.net/epxtY/

like image 186
Kerry Liu Avatar answered Oct 17 '22 16:10

Kerry Liu


Try adding this CSS

.fa-stack{
    width: 1.28571em;    
}
.fa-circle-o.fa-stack-2x {
    font-size: 1.4em;
    top: 2px;
}
.fa-exclamation.fa-stack-1x{
    font-size: 10px;
    top: -3px;
}

http://jsfiddle.net/aZ9g4/12/

like image 23
mechanicals Avatar answered Oct 17 '22 14:10

mechanicals