Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate icon with css on mouse hover

After checking out I implemented below code but the effect is not happening, don't know where its lacking..

<style>


            .rotate {
                -webkit-transition: -webkit-transform 0.4s ease-in-out;
                -moz-transition: -moz-transform 0.4s ease-in-out;
                -o-transition: -o-transform 0.4s ease-in-out;
                -ms-transition: -ms-transform 0.4s ease-in-out;
                transition: transform 0.4s ease-in-out;
                cursor:pointer;
}
            .rotate:hover { 
            color:#afafaf;
            -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
     -ms-transform: rotateZ(360deg);
      -o-transform: rotateZ(360deg);
    transform: rotateZ(360deg);

            }
            </style>

HTML

<div class="col-lg-6 col-md-6 col-sm-12">
                <h2 align="center"><a href="abc.php" class="rotate"> <icon class="icon icon-rocket icon-2x "> </icon> </a> <br />
                Build your Resume </h2>
            </div>

Edit: changed the rotate CLASS from icon to parent

like image 376
Mr AJ Avatar asked Mar 29 '14 17:03

Mr AJ


People also ask

Can we rotate icon using CSS?

The transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, skew, etc., elements.

How do I change my icon rotation?

Screen rotation for an Android smartphoneFrom 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.

How do I rotate an image 90 degrees CSS?

We can add the following to a particular tag in CSS: -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); In case of half rotation change 90 to 45 .


1 Answers

It will work with animation:

<div class="col-lg-6 col-md-6 col-sm-12">
    <h2 align="center"><a href="abc.php" class="rotate"> <icon class="icon icon-rocket icon-2x "> </icon> </a> <br />
        Build your Resume </h2>
</div>

CSS:

.rotate {
    cursor:pointer;
}

.rotate:hover { 
    color:#afafaf;
    -moz-animation: spin .4s 1 linear;
    -o-animation: spin .4s 1 linear;
    -webkit-animation: spin .4s 1 linear;
    animation: spin .4s 1 linear;
}

@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(359deg); }
}

@-moz-keyframes spin {
    0% { -moz-transform: rotate(0deg); }
    100% { -moz-transform: rotate(359deg); }
}

@-o-keyframes spin {
    0% { -o-transform: rotate(0deg); }
    100% { -o-transform: rotate(359deg); }
}

@-ms-keyframes spin {
    0% { -ms-transform: rotate(0deg); }
    100% { -ms-transform: rotate(359deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(359deg); }
}
like image 54
KittMedia Avatar answered Oct 10 '22 10:10

KittMedia