How To Rotate An Image Using Css3 Rotate And Setinterval?
I want to rotate an image using css3 rotate and javascript setinterval. The image should rotate on mouseover. Anyone know how to ?
Solution 1:
You don't even need JavaScript to do it; just put a transition for transform on the element, and apply the rotation on hover. For example:
div {
    background-color: red;
    height: 100px;
    -webkit-transition: -webkit-transform 0.5s ease-in-out;
       -moz-transition:    -moz-transform 0.5s ease-in-out;
         -o-transition:      -o-transform 0.5s ease-in-out;
            transition:         transform 0.5s ease-in-out;
    width: 100px;
}
div:hover {
    -webkit-transform: rotate(90deg);
       -moz-transform: rotate(90deg);
        -ms-transform: rotate(90deg);
         -o-transform: rotate(90deg);
            transform: rotate(90deg);
}
Solution 2:
You can use css3 transform property along with browser specific transform property to rotate and specify degree you want to rotate
<!DOCTYPE HTMLPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><styletype="text/css">div
{
width:200px;
height:100px;
background-color:yellow;
/* Rotate div */transform:rotate(7deg);
-ms-transform:rotate(7deg); /* Internet Explorer */
-moz-transform:rotate(7deg); /* Firefox */
-webkit-transform:rotate(7deg); /* Safari and Chrome */
-o-transform:rotate(7deg); /* Opera */
}
</style></head><body><div>Hello</div></body></html>
Post a Comment for "How To Rotate An Image Using Css3 Rotate And Setinterval?"