html - 数据操作系统动画 : Animation in and then out?

标签 html css animation

我正在尝试合并一些文本,这些文本会在 3 秒后弹回,停留几秒钟然后缩小。我以为我可以做到这一点:

<section class="os-animation" data-os-animation="bounceInDown" data-os-animation-delay="3s" data-os-animation="zoomOutDown" data-os-animation-delay="1s">
    <p id="helper">Filler Text</p>
</section>

但显然我不能,我该怎么做呢?

是否需要 JQuery - 我确实知道如何在 JQuery 中执行此操作(我认为),但我试图避免使用它,因为它确实不是我的强项。

提前谢谢你。

最佳答案

你在找这种东西吗?为此,我使用了 CSS @keyframes,而不是 JQuery

见下文:

<!-- custom fonts - DON'T NEED FOR THE EFFECT --> 
    <link href='https://fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,900,300' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Titillium+Web:400,400italic,600,600italic,300,700' rel='stylesheet' type='text/css'>
<!-- custom fonts - DON'T NEED FOR THE EFFECT -->

    <div class="main-content">
      <span class="bounced-word anim_1">Bounce then leave</span>
     </div>

CSS:

@import "compass/css3";
body {
  background: black;
  color: white;
}
.main-content {
  height: 100vh;
  position: relative;
  text-align: center;
  width: 100%;
}

.main-content .bounced-word {
  color: #56baff;
  display: block;
  font-family: "Titillium Web";
  font-size: 22px;
  font-weight: 600;
  position: absolute;
  text-align: center;
  text-transform: uppercase;
  top: 230px;
  transform: translate3d(0, -200px, 0);
  width: 100%;
}
.main-content .anim_1 {
  animation: 2s bounced-word infinite, 8s hide infinite;
}

@keyframes bounced-word {
  8% {
    transform: translate3d(0, -45px, 0) scaleY(0.4);
    transform-origin: left bottom 0;
  }
  25% {
    transform: translate3d(0, -110px, 0) scaleY(1.4);
  }
  40% {
    transform: translate3d(0, 0, 0) scaleY(0.6);
    transform-origin: left bottom 0;
  }
  50% {
    transform: translate3d(0, 0, 0) scaleY(1.2);
    transform-origin: left bottom 0;
  }
  60% {
    transform: translate3d(0, 0, 0) scaleY(1);
    transform-origin: left bottom 0;
  }
  80% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 50px, 0);
  }
}
@keyframes hide {
  0%, 24% {
    visibility: visible;
  }
  25%, 50% {
    visibility: hidden;
  }
  50%, 75% {
    visibility: hidden;
  }
  75%, 100% {
    visibility: hidden;
  }
}

这可以在这里看到:https://jsfiddle.net/billy_farroll/y27hkq8y/

关于html - 数据操作系统动画 : Animation in and then out?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50614202/

相关文章:

html - 不使用容器、不使用 JS 能否创建两列多元素?

javascript - 当一个 Canvas 放置在另一个 Canvas 之上时文本模糊

javascript - 悬停在图标上时如何对某些文本应用过渡效果?

html - 为什么一个 Div 的动画速度比另一个快

css - 在动画之后转换属性

JavaScript - removeClass 不工作?

html - float 表单元素

jQuery 插件 :select only numerical data from a table

css - 使用 Flexbox 如何防止特定元素继承 Flex 布局?

c++ - 我正在用 OpenGL 编写一个程序来创建一个摆动的摆锤