这是定义歌剧动画关键帧的方法
@-o-keyframes rotate-l {
0% { -o-transform: rotateZ(0deg);}
100% { -o-transform: rotateZ(360deg); }
}
最佳实践和性能
.big, .small{
-webkit-backface-visibility:hidden; /* Chrome and Safari */
-moz-backface-visibility:hidden; /* Firefox */
-ms-backface-visibility:hidden; /* Internet Explorer */
-o-backface-visibility:hidden; /* opera */
backface-visibility:hidden;
}
演示:http: //jsfiddle.net/kougiland/bxTdd/13/
最终代码应如下所示:
html
<div class=hereComes3d>
<span class="big"></span>
<span class="small"></span>
</div>
的CSS:
.hereComes3d{
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 300px;
-moz-perspective: 300px;
-ms-perspective: 300px;
-o-perspective: 300px;
perspective: 300px;
}
.small,.big{
-webkit-perspective-origin: 50% 50%;
-ms-perspective-origin: 50% 50%;
-moz-perspective-origin: 50% 50%;
-o-perspective-origin: 50% 50%;
perspective-origin: 50% 50%;
-webkit-backface-visibility:hidden; /* Chrome and Safari */
-moz-backface-visibility:hidden; /* Firefox */
-ms-backface-visibility:hidden; /* Internet Explorer */
-o-backface-visibility:hidden; /* opera */
backface-visibility:hidden;
}
.big{
position: fixed;
background: #000;
width: 15px;
height: 15px;
top: 18px;
left: 8px;
-webkit-animation: rotation 8s infinite linear;
-moz-animation: rotation 8s infinite linear;
-ms-animation: rotation 8s infinite linear;
-o-animation: rotation 8s infinite linear;
animation: rotation 8s infinite linear;
}
.small{
position: fixed;
background: #000;
width: 10px;
height: 10px;
top: 10px;
left: 30px;
-webkit-animation: rotation2 8s infinite linear;
-moz-animation: rotation2 8s infinite linear;
-ms-animation: rotation2 8s infinite linear;
-o-animation: rotation2 8s infinite linear;
animation: rotation2 8s infinite linear;
}
@-webkit-keyframes rotation {
from { -webkit-transform: rotateZ(0deg);}
to { -webkit-transform: rotateZ(359deg); }
}
@-moz-keyframes rotation {
from { -moz-transform: rotateZ(0deg);}
to { -moz-transform: rotateZ(359deg); }
}
@-ms-keyframes rotation {
from { -ms-transform: rotateZ(0deg);}
to { -ms-transform: rotateZ(359deg); }
}
@-o-keyframes rotation {
from { -o-transform: rotateZ(0deg);}
to { -o-transform: rotateZ(359deg); }
}
@keyframes rotation {
from { transform: rotateZ(0deg);}
to { transform: rotateZ(359deg); }
}
@-webkit-keyframes rotation2 {
0% { -webkit-transform: rotateZ(359deg);}
100% { -webkit-transform: rotateZ(0deg); }
}
@-moz-keyframes rotation2 {
0% { -moz-transform: rotateZ(359deg);}
100% { -moz-transform: rotateZ(0deg); }
}
@-ms-keyframes rotation2 {
0% { -ms-transform: rotateZ(359deg);}
100% { -ms-transform: rotateZ(0deg); }
}
@-o-keyframes rotation2 {
0% { -o-transform: rotateZ(359deg);}
100% { -o-transform: rotateZ(0deg); }
}
@keyframes rotation2 {
0% { transform: rotateZ(359deg);}
100% { transform: rotateZ(0deg); }
}
在这里阅读更多http://dev.opera.com/articles/view/understanding-3d-transforms/