简体   繁体   English

CSS3 动画问题

[英]CSS3 Animations Questions

Trying to have three elements show up one after the other on the page but the following happens.试图让三个元素一个接一个地显示在页面上,但发生了以下情况。

All three elements appear, the first element doesn't do anything (it appears to have already gone through it's animation) Then the second element disappears and then starts it's animation and then the same thing for the third element.所有三个元素都出现了,第一个元素没有做任何事情(它似乎已经完成了它的动画)然后第二个元素消失了,然后开始它是 animation 然后第三个元素也是一样的。

Here's my code, what am I missing here:这是我的代码,我在这里缺少什么:

@-webkit-keyframes reset {
    0% {opacity: 0;}
    100% {opacity: 0;}
}

@-webkit-keyframes fade-in {
0% { opacity: 0; -webkit-transform: scale(.1);}
85% {opacity: 1; -webkit-transform: scale(1.05);}
100% {-webkit-transform: scale(1);}
}


.fade-in {
    -webkit-animation-name: reset, fade-in;
    -webkit-animation-duration: .5s;
    -webkit-animation-timing-function: ease-in;
    -webkit-animation-iteration-count: 1;
}

.fade-in.one {-webkit-animation-delay: 0, .5;}
.fade-in.two {-webkit-animation-delay: 0, 1.5s;}
.fade-in.three {-webkit-animation-delay: 0, 2.5s;}

Thanks in advance提前致谢

The main problem with your code is that you are missing the time unit...您的代码的主要问题是您缺少时间单位......

.fade-in.one {-webkit-animation-delay: 0, .5s;}

While testing your code I took the liberty to simplify it a bit.在测试您的代码时,我冒昧地对其进行了简化。 There is no need to have two separate animations, there is a little known property called -webkit-animation-fill-mode that will allow your animation to remain in its last state.不需要有两个单独的动画,有一个鲜为人知的属性,称为 -webkit-animation-fill-mode,它可以让您的 animation 保留在其最后一个 state 中。 Here is my refactored version:这是我的重构版本:

@-webkit-keyframes fade-in {
    0% { opacity: 0; -webkit-transform: scale(.1);}
    85% {opacity: 1; -webkit-transform: scale(1.05);}
    100% {-webkit-transform: scale(1); opacity: 1;}
}

.fade-in {
  -webkit-animation: fade-in .5s ease-in;
  -webkit-animation-fill-mode: forwards;
  -webkit-animation-iteration-count: 1;
  opacity: 0;
}

.fade-in.one {-webkit-animation-delay: .5s;}
.fade-in.two {-webkit-animation-delay: 1.5s;}
.fade-in.three {-webkit-animation-delay: 2.5s;}

You can check it out here:你可以在这里查看:

http://jsfiddle.net/vqfj7/ http://jsfiddle.net/vqfj7/

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

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