html - CSS 动画在一定时间后开始

标签 html css animation css-animations

一段时间以来,我一直在努力解决这个问题,但到目前为止还没有成功:我想使用 CSS 运行打字动画。动画必须在 7 秒后开始。我不知道该怎么做。我的代码如下所示:

HTML

<div class='background-fullwidth'>    
    <div class="css-typing">
      This text will pop up using an typewriting effect
    </div>        
</div>

CSS

.css-typing  {
    width: 360px;

    white-space: nowrap;
    overflow: hidden;
    -webkit-animation: type 3s steps(50, end);
    animation: type 3s steps(55, end);
    -o-animation: type 5s steps(50, end);
    -moz-animation: type 3s steps(55, end);

    padding: 10px;
}

.background-fullwidth {
  width: 400px;
  background-color: rgba(0, 50, 92, 0.7);
}    

@keyframes type {
    from { width: 0; }
    to { width: 360px; }
}

@-moz-keyframes type {
    from { width: 0; }
    to { width: 360px; }
}

@-webkit-keyframes type {
    from { width: 0; }
    to { width: 360px; }
}

有谁知道如何添加这个计时器 - 假设动画必须在 7 秒后开始?从第 1 秒到第 7 秒,只需显示环绕 DIV(蓝色背景)。

Fiddle 看起来像这样: CSS Animation

最佳答案

您必须使用 3 种不同的动画属性。

  1. animation-delay:帮助您解决7秒后开始动画的基本问题。
  2. 动画迭代计数;此属性可让您决定动画自身重复的次数。将其设置为 1 会将其限制为单个动画实例。
  3. animation-fill-mode:将此属性设置为 forward 将确保在动画结束时宽度保持为 320。

CSS

  animation-delay: 2s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
  width: 0; // So that the animation starts from 0

https://jsfiddle.net/kaminasw/at6mbxyr/ 查看 fiddle

关于html - CSS 动画在一定时间后开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42109985/

相关文章:

html - 是否可以在我的上边距中添加超过 mt-5?

css - valign ="top"在一个单元格中不工作

ios - 如何创建不断增长的 iOS 按钮?

html - 跨同一浏览器的 CSS/HTML 兼容性问题

javascript - 导航栏悬停鼠标

javascript - 如何防止 jQuery 返回顶部按钮需要在移动设备上双击

html - 使用 HTML 和 CSS 在元素具有焦点时设置部分事件

javascript - 响应式设计,以图像为中心

Swift Closure - 无法转换类型 (_) -> () 的值?到预期的参数类型 (() -> ())?

c# - C#中的动画触发器( Storyboard+触发器)