Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font Awesome's fa-spin spinning around wrong center

I'm using this toggle menu template: http://bootsnipp.com/snippets/featured/navigation-sidebar-with-toggle .

I have replaced bootstraps glyphicon with font awesome's

fa fa-cog fa-spin

but the cog is spinning out of boundaries as if the center is not on the same line as the text. I can see that there is some issue with thesizing, but I cannot figure out where, any idea what am I doing wrong?

JSFiffle: https://jsfiddle.net/vidriduch/mpw2r8h2/1/

like image 834
vidriduch Avatar asked Apr 01 '15 13:04

vidriduch


4 Answers

You have a problem in the text indent

.sidebar-nav li {
    line-height: 40px;
    text-indent: 20px; //Remove this rule and use margin
}

And change this class rules

.sub_icon {
    float: right;
    margin-right: 10px;
    margin-top: 10px;
    padding-right: 65px; // remove it
    padding-top: 10px;// remove it
}
like image 60
Luís P. A. Avatar answered Oct 25 '22 15:10

Luís P. A.


I finally found how to fix it :

You have to align the icon.

<i style='text-align: center;' class='fa fa-cog fa-spin' ></i>
like image 44
GP014 Avatar answered Oct 25 '22 16:10

GP014


For me it worked to just add 2px padding to the top.

<i className="far fa-lg fa-spin fa-cog" style="padding-top: 2px" />
like image 22
Rouan van der Ende Avatar answered Oct 25 '22 16:10

Rouan van der Ende


I solved this using flexbox, had a similar problem.
Just add:

text-align: center;
display:flex;
align-items: center;
justify-content: center;

Also, because your code is aligned to the left, you will have to add margin-right: (pixels); to align it according to your code.

like image 21
CONTENT Avatar answered Oct 25 '22 15:10

CONTENT