第一个动画播放完播放第二个动画
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动画一</title>
<style>
body {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
background: #222;
}
.loading {
display: flex;
/*width: 200px;*/
/*height: 200px;*/
/*animation-delay: 10s;*/
}
.dot {
position: relative;
width: 2em;
height: 2em;
margin: 0.8em;
border-radius: 50%;
}
.dot::before {
position: absolute;
content: "";
width: 100%;
height: 100%;
background: inherit;
border-radius: inherit;
animation: wave 2s ease-out infinite;
}
.dot:nth-child(1)::before{
animation-delay:0.2s;
}
.dot:nth-child(2)::before{
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
-o-animation-delay: 0.6s;
animation-delay: 0.6s;
}
.dot:nth-child(3)::before{
-webkit-animation-delay: 0.9s;
-moz-animation-delay: 0.9s;
-o-animation-delay: 0.9s;
animation-delay: 0.9s;
}
.dot:nth-child(4)::before{
-webkit-animation-delay: 1.2s;
-moz-animation-delay: 1.2s;
-o-animation-delay: 1.2s;
animation-delay: 1.2s;
}
.dot:nth-child(5)::before{
-webkit-animation-delay: 1.5s;
-moz-animation-delay: 1.5s;
-o-animation-delay: 1.5s;
animation-delay: 1.5s;
}
@keyframes wave {
50%,
75% {
transform: scale(2.5);
}
80%,
100% {
/*transform: scale(0);*/
opacity: 0;
}
}
</style>
</head>
<body>
<div class="loading">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</body>
<script src="jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function(){
var dots = $(".dot");
var colors = ['#7ef9ff', '#89cff0', '#4682b4', '#0f52ba','#000080'];
// console.log(dots);
for(let i = 1;i<=5;i++){
$(dots[i-1]).css({'background':colors[i-1]
})
// 思考:如何用js控制css伪类元素
}
})
</script>
</html>