首页
学习
活动
专区
圈层
工具
发布

TImed动画
EN

Stack Overflow用户
提问于 2015-06-11 09:09:12
回答 1查看 66关注 0票数 0

我怎么能让动画只播放5秒,然后它就消失了?

以下是来自码页的示例

代码语言:javascript
复制
@import "compass/css3";

@include keyframes(bounce) {
    0%, 20%, 50%, 80%, 100% {
    @include transform(translateY(0));
  }
    40% {
    @include transform(translateY(-30px));
  }
    60% {
    @include transform(translateY(-15px));
  }
}

.arrow {
  position: fixed;
  bottom: 0;
  left: 50%;
  margin-left:-20px;
  width: 40px;
  height: 40px;
}

.bounce {
  @include animation(bounce 2s infinite);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-11 09:19:40

您只需调整css和动画:

代码语言:javascript
复制
@import "compass/css3";

@include keyframes(bounce) {
    0%, 10%, 20%, 30%, 40%, 60%, 70%, 80% {
    @include transform(translateY(0));
  }
    15%, 65% {
    @include transform(translateY(-30px));
  }
    25%,75% {
    @include transform(translateY(-15px));
  }
  80%{
    opacity: 1;
  }
  100%{
     opacity: 0;
  }
  0%{
    opacity: 1;
  }
}


body {
  background: black;
}

.arrow {
  position: fixed;
  bottom: 0;
  left: 50%;
  margin-left:-20px;
  width: 40px;
  height: 40px;
  opacity: 0;
}

.bounce {
  @include animation(bounce 5s);
}

在这里,代码笔http://codepen.io/anon/pen/gpRRVy

希望我能帮上忙

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30776358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档