你好我正在尝试用css在我的页面上做一个打字机文本效果,我得到了一个特殊的片段,它给出了一个打字效果,但它确实发送了循环,我需要它循环
这是我使用的初始代码
<div class="typewriter">
<h1>The cat and the hat.</h1>
</div>
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
overflow: hidden; /* Ensures the content is not revealed until the animation */
border-right: .15em solid orange; /* The typwriter cursor */
white-space: nowrap; /* Keeps the content on a single line */
margin: 0 auto; /* Gives that scrolling effect as the typing happens */
letter-spacing: .15em; /* Adjust as needed */
animation:
typing 3.5s steps(40, end),
blink-caret .75s step-end infinite;
}
/* The typing effect */
@keyframes typing {
from { width: 0 }
to { width: 100% }
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: orange; }
}有没有人可以解释一下如何做这个循环,我在网上读到你需要把无穷大的单词加进去,但是我不知道该把这个加在哪里,请帮帮忙。
发布于 2017-01-24 20:19:20
向.typewriter h1添加animation-iteration-count: infinite;将使其循环。
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
overflow: hidden;
/* Ensures the content is not revealed until the animation */
border-right: .15em solid orange;
/* The typwriter cursor */
white-space: nowrap;
/* Keeps the content on a single line */
margin: 0 auto;
/* Gives that scrolling effect as the typing happens */
letter-spacing: .15em;
/* Adjust as needed */
animation: typing 3.5s steps(40, end), blink-caret .75s step-end infinite;
animation-iteration-count: infinite;
}
/* The typing effect */
@keyframes typing {
from {
width: 0
}
to {
width: 100%
}
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to {
border-color: transparent
}
50% {
border-color: orange;
}
}<div class="typewriter">
<h1>The cat and the hat.</h1>
</div>
https://stackoverflow.com/questions/41828017
复制相似问题