Appearance
文字揭示
Text is uncovered by smoothly sliding a mask across it using clip-path: inset() animation. Creates a cinematic reveal effect.
实时预览
Cinematic Reveal
代码
css
.reveal-wipe {
font-size: 38px;
font-weight: 900;
color: #e2e8f0;
clip-path: inset(0 100% 0 0);
animation: wipe-reveal 2s cubic-bezier(0.77, 0, 0.18, 1) forwards;
}
@keyframes wipe-reveal {
0% { clip-path: inset(0 100% 0 0); }
100% { clip-path: inset(0 0% 0 0); }
}
/* Optional accent line */
.reveal-line {
display: block;
height: 3px;
background: linear-gradient(90deg, #a78bfa, #7c3aed);
border-radius: 2px;
animation: line-sweep 2s cubic-bezier(0.77, 0, 0.18, 1) forwards;
margin-top: 8px;
transform-origin: left;
}
@keyframes line-sweep {
0% { transform: scaleX(0); }
100% { transform: scaleX(1); }
}html
<span class="reveal-wipe">Cinematic Reveal</span>
<span class="reveal-line"></span>纯 CSS 实现的文字揭示文字动画效果——通过渐变、阴影、滤镜和变换等 CSS 属性让文字产生视觉动效。所有文字内容保持可选中、可复制、对搜索引擎完全可见。
快速使用
- 复制 CSS 代码到你的样式文件中
- 在 HTML 中放入对应的文字结构(注意逐字效果需要每个字符包裹
<span>) - 根据你的文字内容调整
animation-delay和文字数量 - 修改颜色和字号以匹配你的品牌风格
使用场景
- 页面主标题:用渐变文字、霓虹发光或逐字弹跳效果吸引用户注意力
- 品牌名称/Logo:3D 文字或故障效果传递技术与设计感
- 营销活动页:彩虹文字、闪烁效果营造促销紧迫感
- 技术博客/文档:打字机效果展示代码片段或技术标语
常见问题
Q: 文字动画在哪些浏览器下兼容? A: 大部分效果所有现代浏览器都支持。需注意:background-clip: text 需 -webkit- 前缀;@property 仅 Chrome/Edge 支持。渐变文字和霓虹发光效果建议加降级方案。
Q: 动画文字会影响 SEO 吗? A: 不会。文字内容仍然在 HTML 中正常渲染,搜索引擎能完整抓取。CSS 动画只影响视觉呈现,不改变 DOM 结构和文本可访问性。
Q: 如何让逐字动画适配任意长度的文字? A: 用 JavaScript 动态给每个字符包裹 <span> 并设置 animation-delay: calc(var(--i) * 0.05s),或使用 CSS animation-delay 配合 nth-child 错位。
浏览器兼容性
| 浏览器 | 兼容性 |
|---|---|
| Chrome / Edge | ✅ 完全支持(含 @property) |
| Firefox | ✅ 基本支持(不含 @property) |
| Safari | ✅ 基本支持(需 -webkit-background-clip) |
| 移动端浏览器 | ✅ 完全支持 |
| IE 11 | ❌ 渐变文字等高级效果不支持 |
使用说明
| 属性 | 说明 |
|---|---|
clip-path: inset(0 100% 0 0) | Hides text by clipping from the right |
clip-path: inset(0 0% 0 0) | Fully reveals text (no clipping) |
cubic-bezier(0.77, 0, 0.18, 1) | Smooth deceleration easing for cinematic feel |
animation-fill-mode: forwards | Keeps text visible after animation ends |
transform-origin: left | Line sweeps from left to right |
Tip: Reverse the direction by changing inset(0 100% 0 0) to inset(0 0 0 100%) for a right-to-left wipe.