小编Ioa*_*rei的帖子

文本完成后如何停止光标

我的网页有打字效果,但有一点问题。文本输入完成后,闪烁的光标会一直移动到行尾。我如何让它在最后一个字母之后留下来?

这是基本的,但也许我需要添加更多或修改它?

.typewriter h1{
  position: relative;
  top: 7em;
  width: fit-content;
  overflow: hidden;
  border-right: .15em solid white;
  white-space: nowrap;
  margin: 0 auto;
  letter-spacing: .15em;
  animation: typing 3.5s steps(100, end),
            blink-caret .75s step-end infinite;
}

@keyframes typing{
  from {width: 0}
  to {width: 100%}
}

@keyframes blink-caret{
  from, to {border-color: transparent}
  50% {border-color: white}
}
Run Code Online (Sandbox Code Playgroud)
<div class="typewriter">
    <h1>Welcome to my website</h1>
</div>
Run Code Online (Sandbox Code Playgroud)

css animation typing

0
推荐指数
1
解决办法
1045
查看次数

标签 统计

animation ×1

css ×1

typing ×1