扫描线入场采用clip-path(裁切路径)+ 复制文字层 + 伪元素扫描线。
01 · Scanline / 扫描线入场 点击展开代码 展开
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Scanline / 扫描线入场</title>
<style>
.l1-motion-01{min-height:240px;
display:grid;
place-items:center;
position:relative;
overflow:hidden;
background:#fff;
color:#34383d;
font-family:Arial, Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimHei", sans-serif;}
.l1-motion-01-box{position:relative;
z-index:2;
text-align:center;
max-width:88%;}
.l1-motion-01-title{font-size:36px;
line-height:1.05;
font-weight:850;
letter-spacing:.04em;
white-space:nowrap;}
.l1-motion-01-subtitle{margin-top:9px;
font-size:18px;
line-height:1;
font-weight:760;
letter-spacing:.03em;
white-space:nowrap;}
.l1-motion-01-split .l1-motion-01-title span,
.l1-motion-01-split .l1-motion-01-subtitle span{display:inline-block;}
.l1-motion-01-title,
.l1-motion-01-subtitle{position:relative;color:rgba(52,56,61,.18);overflow:hidden;}
.l1-motion-01-title::before,
.l1-motion-01-subtitle::before{content:attr(data-text);position:absolute;inset:0;color:#34383d;clip-path:inset(0 100% 0 0);animation:l1-motion-01-scanReveal 3000ms cubic-bezier(.22,.72,.17,1) infinite;}
.l1-motion-01-title::after,
.l1-motion-01-subtitle::after{content:"";position:absolute;top:-35%;bottom:-35%;left:-12%;width:2px;background:linear-gradient(to bottom,transparent,#34383d,transparent);box-shadow:0 0 18px rgba(52,56,61,.28);animation:l1-motion-01-scanLine 3000ms cubic-bezier(.22,.72,.17,1) infinite;}
.l1-motion-01-subtitle::before,
.l1-motion-01-subtitle::after{animation-delay:110ms;}
@keyframes l1-motion-01-scanReveal{0%{clip-path:inset(0 100% 0 0)}42%,72%{clip-path:inset(0 0 0 0)}100%{clip-path:inset(0 100% 0 0)}}
@keyframes l1-motion-01-scanLine{0%{left:-12%;opacity:0}8%{opacity:1}42%{left:108%;opacity:1}60%,100%{left:108%;opacity:0}}
</style>
</head>
<body>
<div class="l1-motion-01">
<div class="l1-motion-01-box">
<div class="l1-motion-01-title" data-text="标题文字动画">标题文字动画</div>
<div class="l1-motion-01-subtitle" data-text="Title Motion Lib">Title Motion Lib</div>
</div>
</div>
</body>
</html>
<!-- Scanline / 扫描线入场 -->
<div class="l1-motion-01">
<div class="l1-motion-01-box">
<div class="l1-motion-01-title" data-text="标题文字动画">标题文字动画</div>
<div class="l1-motion-01-subtitle" data-text="Title Motion Lib">Title Motion Lib</div>
</div>
</div>
<style>
.l1-motion-01{min-height:240px;
display:grid;
place-items:center;
position:relative;
overflow:hidden;
background:#fff;
color:#34383d;
font-family:Arial, Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimHei", sans-serif;}
.l1-motion-01-box{position:relative;
z-index:2;
text-align:center;
max-width:88%;}
.l1-motion-01-title{font-size:36px;
line-height:1.05;
font-weight:850;
letter-spacing:.04em;
white-space:nowrap;}
.l1-motion-01-subtitle{margin-top:9px;
font-size:18px;
line-height:1;
font-weight:760;
letter-spacing:.03em;
white-space:nowrap;}
.l1-motion-01-split .l1-motion-01-title span,
.l1-motion-01-split .l1-motion-01-subtitle span{display:inline-block;}
.l1-motion-01-title,
.l1-motion-01-subtitle{position:relative;color:rgba(52,56,61,.18);overflow:hidden;}
.l1-motion-01-title::before,
.l1-motion-01-subtitle::before{content:attr(data-text);position:absolute;inset:0;color:#34383d;clip-path:inset(0 100% 0 0);animation:l1-motion-01-scanReveal 3000ms cubic-bezier(.22,.72,.17,1) infinite;}
.l1-motion-01-title::after,
.l1-motion-01-subtitle::after{content:"";position:absolute;top:-35%;bottom:-35%;left:-12%;width:2px;background:linear-gradient(to bottom,transparent,#34383d,transparent);box-shadow:0 0 18px rgba(52,56,61,.28);animation:l1-motion-01-scanLine 3000ms cubic-bezier(.22,.72,.17,1) infinite;}
.l1-motion-01-subtitle::before,
.l1-motion-01-subtitle::after{animation-delay:110ms;}
@keyframes l1-motion-01-scanReveal{0%{clip-path:inset(0 100% 0 0)}42%,72%{clip-path:inset(0 0 0 0)}100%{clip-path:inset(0 100% 0 0)}}
@keyframes l1-motion-01-scanLine{0%{left:-12%;opacity:0}8%{opacity:1}42%{left:108%;opacity:1}60%,100%{left:108%;opacity:0}}
</style>