用css 现实打字机效果

直接写代码,真正使用注意,一个是 width的值,二是注意在不同浏览器的兼容问题。或者用gif 图片代替

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Repeated Typing Effect</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <div class="typing-effect">
    用CSS实现实现打字机效果!!!
  </div>
  
  <style>
	 @keyframes typing {
	   0% {
	     width: 0;
	   }
	   100% {
	     width: 100%;
	   }
	 }
	 
	 @keyframes blink-caret {
	   0%, 100% {
	     border-color: transparent;
	   }
	   50% {
	     border-color: black;
	   }
	 }
	 
	 .typing-effect {
	   overflow: hidden;
	   border-right: 4px solid black;
	   white-space: nowrap;
	   width: 550px;
	   max-width: 550px;
	   animation: typing 9.5s steps(40, end) forwards, blink-caret 0.75s step-end infinite;
	   animation-iteration-count: infinite; /* 让打字机效果无限重复 */
	   font-size: 35px;
		background: linear-gradient(to right, #0055ff, #00aaff);
		font-weight: 600;
	   -webkit-background-clip: text;
	   -webkit-text-fill-color: transparent;
	   	line-height: 1.5;
	 } 
  </style>
  
</body>
</html>
相关推荐
threerocks1 小时前
什么?我连 A2A、MCP 都没学会,现在又来了 AG-UI、A2UI.
前端·aigc·ai编程
牛奶2 小时前
如何自己写一个浏览器插件?
前端·chrome·浏览器
亿元程序员3 小时前
为什么Cocos都4.0了还有人用2.x?
前端
MomentYY3 小时前
AI 到底是“懂”,还是在“猜”?
前端·人工智能·ai编程
鹏毓网络科技3 小时前
Cursor Rules 文件配置实战:3 个隐藏参数让我每月少写 40% 样板代码
前端·github
没烦恼3013 小时前
无痕模式下 HTTP\-First 拦截引发的“页面刷新”误判
前端
文心快码BaiduComate3 小时前
从个人提效到组织提效:Comate辅助构建自我进化的AI研发系统
前端·程序员
hunterandroid3 小时前
Compose 状态管理:remember、rememberSaveable 与状态提升
前端
星栈4 小时前
Dioxus 接数据库最容易写歪的 3 个地方:sqlx + SQLite 怎么接才顺
前端·rust·前端框架
晴虹4 小时前
vue3-scroll-more:横向滚动条-元素或页签过多滚动显示处理的组件
前端·vue.js