CSS3文本背景图像动画填充效果
CSS3文本背景图像动画填充效果

html:
<div class="container-text">星辰大海</div>
css:
*{
margin: 0;
padding: 0;
}
.container-text{
width: 50%;
margin: 100px auto;
background: url('./img/sea.jpg');
font-size: 200px;
font-family: '微软雅黑';
font-weight: 800;
padding-top: 50px;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
animation: filling 3s ease forwards;
}
@keyframes filling{
from{
background-position: center 25%;
}
to{
background-position: center 50%;
}
}垂直向上移动背景图,直到最后一帧。
forwards当动画完成后,保持最后一帧的状态(也就是最后一个关键帧中定义的状态)。
吐槽一下


还没有留言,还不快点抢沙发?