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>
相关推荐
Aska_Lv3 分钟前
mysql---什么是OnlineDDL
前端·架构
酒茶白开水15 分钟前
React七案例中
前端·react.js
WEIII19 分钟前
全网都找不到!小程序集成第三方 WASM npm 包
前端·微信小程序·webassembly
Mintopia24 分钟前
Node.js 中 crypto 模块的实用指南与应用示例
前端·javascript·node.js
北京_宏哥26 分钟前
🔥Jmeter(六) - 从入门到精通 - 建立数据库测试计划(详解教程)
前端·jmeter·性能优化
jzy371127 分钟前
告别浏览器兼容性警告!Ambari 页面“DOMNodeInserted”弃用问题终极修复指南
前端·http
江城开朗的豌豆32 分钟前
CSS篇:APP适配终极方案:Flexible、REM、Viewport全解析
前端
pink大呲花32 分钟前
Vue.js 中 v-model 的使用及其原理
前端·javascript·vue.js
打野赵怀真40 分钟前
第 114 题:找出字符串中连续出现最多的字符和个数
前端·javascript
xll_00743 分钟前
VUE3+TS+elementplus+Django+MySQL实现从前端增加数据存入数据库,并显示在前端界面上
前端·python·mysql·typescript·django·vue