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>
相关推荐
雯0609~9 小时前
hiprint:实现项目部署与打印3-vue版本-独立出模板设计与模板打印页面
前端·vue.js·arcgis
杜子不疼.9 小时前
【Linux】教你在 Linux 上搭建 Web 服务器,步骤清晰无门槛
linux·服务器·前端
程序员Agions10 小时前
useMemo、useCallback、React.memo,可能真的要删了
前端·react.js
滕青山10 小时前
Vue项目BMI计算器技术实现
前端·vue.js
子兮曰10 小时前
深入浏览器指纹:Canvas、WebGL、Audio是如何暴露你的身份的?
前端·浏览器·canvas
月亮补丁10 小时前
AntiGravity只能生成 1:1 图片?一招破解尺寸限制
前端
何中应10 小时前
MindMap部署
前端·node.js
NAGNIP10 小时前
程序员效率翻倍的快捷键大全!
前端·后端·程序员
一个网络学徒10 小时前
python5
java·服务器·前端
tiantian_cool10 小时前
Claude Opus 4.6 模型新特性(2026年2月5日发布)
前端