简体   繁体   English

CSS 动画翻转时钟

[英]CSS animation Flip Clock

i have a problem when making Flip Clock animation我在制作翻转时钟动画时遇到问题

the animation will perform like this reference动画将像此参考一样执行

reference : http://hilios.github.io/jQuery.countdown/参考http : //hilios.github.io/jQuery.countdown/

so far, this is my work.到目前为止,这是我的工作。

demo : https://jsfiddle.net/s3qk25m7/1演示https : //jsfiddle.net/s3qk25m7/1

i try this one :我试试这个:

HTML : HTML :

<div class="time">
  <span class="count top flipTop">2</span>
    <span class="count top">1</span>
    <span class="count bottom flipBottom">1</span>
  <span class="count bottom">2</span>
</div>

CSS : CSS :

.time {position: relative; height: 95px; width: 65px;
  perspective: 200px; backface-visibility: hidden;
  transform: translateZ(0); transform: translate3d(0,0,0);
}
.count {background: #202020; color: #f8f8f8; display: block;
  font-size: 2em; line-height: 2.4em; overflow: hidden;
  position: absolute; text-align: center;
  top: 0; width: 100%;
}
.top {height: 50%; line-height:95px; transform-origin: 50% 100%; }
.bottom {line-height: 0; height: 50%; top: 50%; transform-origin: 50% 0; }

@keyframes flipTop {
  from {
      transform: rotateX(0deg);
  }
  to {
      transform: rotateX(-90deg);
  }
}
@keyframes flipBottom {
    from {
        transform: rotateX(90deg);
    }
    to {
        transform: rotateX(0deg);
    }
}

.flipTop {
    animation-name: flipTop;
    animation-duration: 0.25s;
    animation-fill-mode: both;
}
.flipBottom {
    animation-name: flipBottom;
    animation-duration: 0.25s;
     animation-delay: 0.25s;
    animation-fill-mode: both;
}

the animation not working properly.动画无法正常工作。 how to solve this issue?如何解决这个问题?

what's wrong with my code?我的代码有什么问题?

thanks in advance...提前致谢...

The issue is that the animated div is behind the static.问题是动画 div 在静态后面。

To fix this add z-index: 1 to your .flipPosition class.要解决此问题,请将z-index: 1添加到您的.flipPosition类。

Check out this updated fiddle看看这个更新的小提琴

Edit: note that the lower div's number seems to be updated too early编辑:请注意,较低的 div 数字似乎更新得太早了

Edit 2: I just realized that ngAnimateSwap would probably be perfect for this!编辑 2:我刚刚意识到ngAnimateSwap可能是完美的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM