先放效果图:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>加载光效</title>
<style>
.line{
width: 100%;
height: 50px;
background-image: url('https://d1.lanrentuku.com/upload/img/2020/09/04/5f5207220a579__2.png');
background-size: 20% 100%;
background-repeat:no-repeat;
animation: move 1.5s linear infinite;
display: flex;
align-items: center;
}
.line::after{
content: "";
display: block;
width: 100%;
height: 3%;
z-index: -1;
background-color: rgb(253,130,153);;
}
@keyframes move {
0% {
background-position-x: 0px;
}
100% {
background-position-x: 100%;
}
}
</style>
</head>
<body>
<div class="line"></div>
</body>
</html>