我有这个jsfiddle,我认为它会使这个图像不断旋转,但事实并非如此。
使用的HTML:
<img class="rotate" src="http://www.arcelormittal.com/distributionsolutions/content/images/reload_captcha.png" />
使用的CSS:
.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);
}
为什么图像不经常旋转?
答案 0 :(得分:4)
您需要使用动画,因为它没有开始和结束来转换:
.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);
}
}
答案 1 :(得分:0)
<!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>