css实现文字打字机效果


html

typescript 复制代码
<body>
    <p class="line animation">
        我和我的祖国,一刻也不能分割
    </p>
</body>

css

typescript 复制代码
 <style type="text/css">
        html,
        body {
            height: 100%;
        }

        body {
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            /* background: #222; */
        }

        .line {
            width: 674px;
            border-right: 2px solid #eee;
            font-size: 28px;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            color: #5ec4ff;
            background: linear-gradient(0deg, #5ec4ff 0%, #ffffff 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .animation {
            animation: grow 4s steps(44) 1s normal both,
                blink 0.5s steps(44) infinite normal;
        }

        @keyframes grow {
            from {
                width: 0;
            }

            to {
                width: 400px;
            }
        }

        @keyframes blink {
            from {
                border-right-color: #eee;
            }

            to {
                border-right-color: #222;
            }
        }
    </style>
相关推荐
恋猫de小郭7 分钟前
Flutter 官方 LLM 动态 UI 库 flutter_genui 发布,让 App UI 自己生成 UI
android·前端·flutter
kymjs张涛30 分钟前
零一开源|前沿技术周刊 #15
前端·javascript·面试
reacx31 分钟前
# 第三章:状态管理架构设计 - 从 Zustand 到 React Query 的完整实践
前端
古夕32 分钟前
Vue3 + vue-query 的重复请求问题解决记录
前端·javascript·vue.js
不知名程序员第二部32 分钟前
前端-业务-架构
前端·javascript·代码规范
Bug生产工厂33 分钟前
React支付组件设计与封装:从基础组件到企业级解决方案
前端·react.js·typescript
小喷友33 分钟前
阶段三:进阶(Rust 高级特性)
前端·rust
华仔啊33 分钟前
面试官:请解释一下 JS 的 this 指向。别慌,看完这篇让你对答如流!
前端·javascript
Strayer33 分钟前
Tauri2.0打包构建报错
前端
小高00735 分钟前
💥💥💥前端“隐藏神技”:15 个高效却鲜为人知的 Web API 大起底
前端·javascript