How to align font-awesome icon vertically
6 answers
.fa.fa-battery-full {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<i class="fa fa-battery-full" aria-hidden="true"></i>
0
source to share
Using your own font class classes from the documentation
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<i class="fa fa-battery-full fa-rotate-270" aria-hidden="true"></i>
-
fa-rotate-90
-
fa-rotate-180
-
fa-rotate-270
-
fa-flip-horizontal
-
fa-flip-vertical
+4
source to share
You can achieve this in two ways: by using FA classes or by adding some transform styles to the tag, or by adding another class with the following styles.
To use the FA classes, use the "fa-rotate-270" class to rotate the icon 270 degrees clockwise:
<i class="fa fa-battery-full fa-rotate-270"/></i>
The above rotation only supports rotation operations '90' '180' and '270'.
If you want to apply the transform instead (you can probably tweak it further), your code will look like this:
<i class="fa fa-battery-full" style="transform: rotate(-90deg);" aria-hidden="true"></i>
Also note that the following transforms are cross-browser compatible if you want to be compatible.
-moz-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
+3
source to share
Use CSS to rotate the icon.
.fa.fa-battery-full { transform: rotate(270deg); }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<i class="fa fa-battery-full" aria-hidden="true"></i>
0
source to share