<img class="image" src="" alt="" width="120" height="120">
无法让这个动画图像工作,它应该做360度旋转 .
我想下面的CSS有些问题,因为它只是保持不动 .
.image {
float: left;
margin: 0 auto;
position: absolute;
top: 50%;
left: 50%;
width: 120px;
height: 120px;
margin-top: -60px;
margin-left: -60px;
-webkit-animation-name: spin;
-webkit-animation-duration: 4000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-name: spin;
-moz-animation-duration: 4000ms;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
-ms-animation-name: spin;
-ms-animation-duration: 4000ms;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: linear;
animation-name: spin;
animation-duration: 4000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
@-ms-keyframes spin {
from {
-ms-transform: rotate(0deg);
} to {
-ms-transform: rotate(360deg);
}
}
@-moz-keyframes spin {
from {
-moz-transform: rotate(0deg);
} to {
-moz-transform: rotate(360deg);
}
}
@-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
} to {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
from {
transform: rotate(0deg);
} to {
transform: rotate(360deg);
}
}
}
5 回答
如果你想翻转图像,你可以使用它 .
要实现360度旋转,这里是Working Solution .
The HTML:
The CSS:
你必须将鼠标悬停在图像上,你将获得360度旋转效果 .
PS:添加一个
-webkit-
扩展名,以便在chrome和其他webkit浏览器上工作 . 你可以查看webkit的更新小提琴 HERE这应该对你有帮助
下面的jsfiddle链接将帮助您了解如何旋转图像 . 我使用相同的旋转时钟拨号 .
http://jsfiddle.net/xw89p/
其中:•t:当前时间,
•b:求恩 Value ,
•c:更改值,
•d:持续时间,
•x:未使用
无缓和(线性缓和):函数(x,t,b,c,d){return b(t / d)* c; }
这是 demo . 正确的动画CSS:
关于代码的一些注意事项:
您已嵌套
.image
规则中的关键帧,这是不正确的float:left
不适用于绝对定位的元素看看caniuse:IE10不需要
-ms-
前缀我有一个使用与你相同的旋转图像: