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>
相关推荐
We་ct1 小时前
LeetCode 77. 组合:DFS回溯+剪枝,高效求解组合问题
开发语言·前端·算法·leetcode·typescript·深度优先·剪枝
KerwinChou_CN1 小时前
什么是流式输出,后端怎么生成,前端怎么渲染
前端
爱上妖精的尾巴1 小时前
8-20 WPS JS宏 正则表达式-懒惰匹配
服务器·前端·javascript
网络点点滴1 小时前
组件通信props方式
前端·javascript·vue.js
二十雨辰2 小时前
[小结]-线上Bug监控
前端·bug
前端技术2 小时前
【鸿蒙实战】从零打造智能物联网家居控制系统:HarmonyOS Next分布式能力的完美诠释
java·前端·人工智能·分布式·物联网·前端框架·harmonyos
CHU7290352 小时前
指尖践行环保——旧衣服回收小程序前端功能玩法详解
前端·小程序
LawrenceLan2 小时前
38.Flutter 零基础入门(三十八):网络请求实战 http、dio —— 获取列表与刷新 UI
开发语言·前端·flutter·dart
csdn_aspnet2 小时前
Asp.Net Core 10.0 中的 Blazor 增强功能
前端·后端·asp.net·blazor·.net10
SuperEugene2 小时前
Excel 上传解析 + 导出实战:Vue+xlsx 避坑指南|Vue生态精选
前端·javascript·vue.js·excel·xlsx·vxetable