Get Off My Lawn
Get Off My Lawn

Reputation: 36351

CSS Image Rotation Transformation

I have this jsfiddle, and I thought that it would make this image constantly rotate, but it doesn't.

The HTML Used:

<img class="rotate" src="http://www.arcelormittal.com/distributionsolutions/content/images/reload_captcha.png" />

The CSS Used:

.rotate{
    -webkit-transition-duration: 0.8s;
    -moz-transition-duration: 0.8s;
    -o-transition-duration: 0.8s;
    transition-duration: 0.8s;
    -webkit-transition-property: -webkit-transform;
    -moz-transition-property: -moz-transform;
    -o-transition-property: -o-transform;
    transition-property: transform;

    -webkit-transform:rotate(360deg);
    -moz-transform:rotate(360deg);
    -o-transform:rotate(360deg);
    transform:rotate(360deg);
} 

Why isn't the image constantly rotating?

Upvotes: 0

Views: 14692

Answers (2)

user3636631
user3636631

Reputation: 1

<!DOCTYPE html>
<html>
<head>
    <style> 
        div
        {
            width:200px;
            height:100px;
            margin-top:100px;
            background-color:yellow;
            /* Rotate div */
            transform:rotate(90deg);
            -ms-transform:rotate(90deg); /* IE 9 */
            -webkit-transform:rotate(90deg); /* Opera, Chrome, and Safari */
        }
    </style>
</head>
<body>
    <div><img src="http://www.rltech.co.in/01/images/rllogo.png"/></div>
</body>
</html>

Upvotes: 0

kalley
kalley

Reputation: 18472

You'll need to use an animation because it doesn't have a start and an end to transition from:

.rotate {
    -webkit-animation: spin .8s infinite linear;
    animation: spin .8s infinite linear;
}
@-webkit-keyframes spin {
    100% { -webkit-transform: rotate(360deg); }
}
@-moz-keyframes spin {
    100% { -moz-transform: rotate(360deg); }
}
@keyframes spin {
    100% {
        -moz-transform:rotate(360deg);
        -o-transform:rotate(360deg);
        transform:rotate(360deg);
    }
}

Upvotes: 4

Related Questions