实现纯h5+css 骨架屏效果,以下是全部代码
<!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>Document</title>
<style>
ul {
list-style: none;
padding: 0;
}
li {
list-style: none;
height: 20px;
margin: 6px 4px;
border-radius: 4px;
background: linear-gradient(90deg, rgba(0, 0, 0, 0.06) 25%, rgba(0, 0, 0, 0.15) 37%, rgba(0, 0, 0, 0.06) 63%);
animation-name: loading;
animation-duration: 1.4s;
animation-timing-function: ease;
animation-iteration-count: infinite;
background-size: 400% 100%;
}
@keyframes loading {
0% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
</style>
</head>
<body>
<ul>
<li style="width: 50%;"></li>
<li></li>
<li></li>
<li></li>
<li style="width: 30%;"></li>
</ul>
</body>
</html>
效果展示 (截的屏) :