html - 打字动画使用纯css实现

标签 html css

嘿,我正在按照本指南创建文字动画:http://lea.verou.me/2011/09/pure-css3-typing-animation-with-steps/ .但是我到了一个点,每个 div 元素之后都有闪烁的光标,但动画没有发生。 你们介意查看一下,看看可能是什么问题吗?

这是我的 HTML 结构:

<div class="line1">
    &lt;!DOCTYPE html><span>&nbsp;</span>
</div>
<div class="line2">
    &lt;html><span>&nbsp;</span>
</div>
<div class="line3">
    &emsp;&lt;head><span>&nbsp;</span>
</div>
<div class="line4">
    &emsp;&emsp;&lt;title&gt;
    <p>Welcome! :)</p>
    &lt;/title><span>&nbsp;</span>
</div>

这是一个jfiddle链接到我的 css 代码和 html 代码

非常感谢您的帮助!

最佳答案

试试这个简单的 CSS

p{
  color: #3D3F46;
  font-size: 20px;
  margin: 10px 0 0 10px;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  animation: type 10s steps(60, end);
}

p:nth-child(2){
  animation: type2 8s steps(60, end);
}

p a{
  color: #3D3F46;
  text-decoration: none;
}

span{
  animation: blink 1s infinite;
}

@keyframes type{
  from { width: 0; }
}

@keyframes type2{
  0%{width: 0;}
  50%{width: 0;}
  100%{ width: 100; }
}

@keyframes blink{
  to{opacity: .0;}
}
<p>Hi  This is the sample text for typing effect using css <span>|</span></p>

关于html - 打字动画使用纯css实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41605417/

相关文章:

javascript - 在 dom 中,html 元素和片段之间的功能区别是什么?

jquery - 在 jQuery 中获取 CSS 规则的百分比值

javascript - SVG 上的鼠标行为滞后

html - 我无法摆脱导航链接后面的黑色背景

javascript - 在 HTML5 应用程序中使用 IFRAME

html - 如何在标题值中换行

html - 为什么我的@media 查询在特定行之后没有被代码编辑器注册?

javascript - 在没有继承 css 影响的情况下格式化 div 元素内的元素

javascript - 下拉列表中的滚动条

javascript - 加载页面时快速重定向