jquery - 是否可以在 CSS3 中的同一元素上链接动画

标签 jquery html animation css webkit

我想在 CSS3 中旋转并从右向左移动任何图像。在短暂的延迟之后,我想将图像从它的新当前状态向上移动并将其从容器中淡出。

我能够使用关键帧和一些 jQuery 来触发动画很容易地实现第一个动画,但是每当我尝试添加第二个动画时,图像都会返回到它的初始状态,然后执行第二个动画。这是我目前所拥有的

@-webkit-keyframes image-slide-right-to-left {
    0%   { opacity: 1; }
100% { opacity: 1;  -webkit-transform: translate(-400px, 60px) rotate(-55deg);}
}

@-webkit-keyframes image-slide-up-and-out {
        0%   { opacity: 1; }
        100% { opacity: 1;  -webkit-transform: translate(400px, 260px) rotate(-55deg);}
    }

.image-slide-right-to-left{
        -webkit-animation: image-slide-right-to-left 3s, image-slide-up-and-out 3s;
        -moz-animation:    image-slide-right-to-left 3s, image-slide-up-and-out 3s;
        -ms-animation:     image-slide-right-to-left 3s, image-slide-up-and-out 3s;

        -webkit-animation-fill-mode: forwards;
        -moz-animation-fill-mode: forwards;
        -ms-animation-fill-mode: forwards;

        -webkit-animation-delay: 4s, 8s;
        -moz-animation-delay: 4s, 8s;
        -ms-animation-delay: 4s, 8s;

        animation-timing-function: ease-in-out;
    }

<script>
    $(window).load(function() {
        $('.feature1 .implant').addClass('image-slide-right-to-left');
</script>

最佳答案

是的,可以在同一个元素上链接动画:

示例:

.animate-this {
   -webkit-animation:
      first-animation 2s infinite,
      another-animation 1s;
}

Mr. Google 上进行简单搜索!

您可以阅读关于 animations syntax here! 的很好的教程

来自 fellow Stacker! 的文章

一些元素的一个很好的例子是 chained animated .


已编辑

添加了一个 simple Fiddle example使用动画 gif 设置为背景的 div 动画。

关于jquery - 是否可以在 CSS3 中的同一元素上链接动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10543290/

相关文章:

javascript - 使用 Angular 简单上一个\下一个 slider

javascript - 显示 : none changes to display: inline by itself?

css - 加载动画并锁定页面上的所有元素

javascript - 如何在 Vanilla JS 中从位置过渡到动画?

html - 垂直div居中

javascript - 滚动时 JQuery 动画滞后

jquery - 根据数据库验证电子邮件格式和唯一性

javascript - 如何从一个div中选择一个元素到另一个?

html - Border Image gif 不会在 Edge 42 中为 svg 设置动画

html - 本地路径不工作