I am trying to a rotate an icon with transform: rotateZ(90deg)
but it seems like it is ignoring it.
When I add a transition to the icon I can see the animation of the icon rotating but then it snaps back into place when it is done animating.
Here it is:
@import url(http://weloveiconfonts.com/api/?family=fontawesome);
/* fontawesome */
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
span {
transition: 2s;
border: 1px solid red;
font-size: 500px;
}
span:hover {
transform: rotateZ(90deg);
}
<span class="fontawesome-download-alt"></span>
Screen rotation for an Android smartphone From the top-right of the screen, swipe down and to the left two times. This action brings up a small menu of icons. From the menu, tap the icon that says Auto-rotate, as shown in the images below.
To arbitrarily rotate and flip icons, use the fa-rotate-* and fa-flip-* classes when you reference an icon.
It's because the <span>
is an inline element, and inline elements are not "transformable." Simply change it's display
property to inline-block
.
transformable element
A transformable element is an element in one of these categories: an element whose layout is governed by the CSS box model which is either a block-level or atomic inline-level element, or whose display property computes to table-row, table-row-group, table-header-group, table-footer-group, table-cell, or table-caption [CSS21]
According to the W3C, inline elements are not listed as "transformable".
@import url(http://weloveiconfonts.com/api/?family=fontawesome);
/* fontawesome */
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
span {
transition: 2s;
border: 1px solid red;
font-size: 500px;
display: block;
/* ^^ Change this */
}
span:hover {
transform: rotateZ(90deg);
}
<span class="fontawesome-download-alt"></span>
Use DIV, not SPAN; set your width and height and add display:block;
Also, add -webkit-transition: 2s;
and -webkit-transform:rotateZ(90deg);
for it to work on all browsers. See below code.
<style>
@import url(http://weloveiconfonts.com/api/?family=fontawesome);
/* fontawesome */
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
div {
-webkit-transition: 2s;
transition: 2s;
border: 1px solid red;
font-size: 500px;
display: block;
width: 470px;
height: 470px;
}
div:hover {
-webkit-transform:rotateZ(90deg);
transform: rotateZ(90deg);
}
</style>
<div class="fontawesome-download-alt"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With