【发布时间】:2016-02-25 00:32:04
【问题描述】:
考虑this JSFiddle rotation example
HTML:
<div class="container">
<div class="coin">
<div class="face heads">
Hey!
</div>
<div class="face tails">
Ho!
</div>
</div>
</div>
CSS:
@keyframes rotation {
0% {
transform: rotate3d(0, 1, 0, 0deg);
}
50% {
transform: rotate3d(0, 1, 0, 180deg);
}
100% {
transform: rotate3d(0, 1, 0, 360deg);
}
}
.container {
background-color: blue;
width: 100px;
height: 100px;
}
.coin {
position: relative;
top: 25px;
left: 25px;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
animation-name: rotation;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-duration: 2.5s;
}
.face {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
}
.heads {
background-color: green;
z-index: 2;
}
.tails {
background-color: gray;
z-index: 1;
}
如您所见,众所周知的.coin 由两个.faces 组成,由两个重叠的divs 和不同的z-index 表示。
当整个.coin 围绕Y 轴旋转时,动画是否应该在达到关键帧的50% 时渲染.tails 面?
还是我对 HTML5 期望过高?还是我只是做错了什么?
提前感谢您的澄清!
【问题讨论】:
-
@Paulie_D 好点,谢谢。我编辑了问题。
标签: css html animation css-animations