打字机效果 · 文字
前端Wiki/CSS 特效合集/打字机效果

打字机效果

文字逐字出现,末尾光标持续闪烁

← 返回 文字 类特效列表
Hello, 纯 CSS 打字机!

上方为纯 CSS 实时演示,直接将鼠标移上去 / 点击感受效果

CSS 代码

CSS
.fx .type{display:flex;justify-content:center;margin:44px 0;font-size:24px;font-family:Consolas,monospace}
.fx .type .t{overflow:hidden;white-space:nowrap;border-right:2px solid #f778ba;width:0;animation:kfx-type 4s steps(13,end) forwards,kfx-caret .8s step-end infinite}
@keyframes kfx-type{to{width:15em}}
@keyframes kfx-caret{50%{border-color:transparent}}

HTML 结构

HTML
<div class="fx">
<div class="type"><span class="t">Hello, 纯 CSS 打字机!</span></div>
</div>
实现要点:纯 CSS 打字机 = steps() 步进宽度 + 右边框光标闪烁

其它文字类特效

回到 前端Wiki 首页 · CSS 特效合集