Html
<div class="boxName">
<div class="box"></div>
<div class="ball">
<p></p>
<p></p>
</div>
</div>
添加关键帧
@keyframes boxFram {
from {
box-shadow: 200px 0 0 -40px rgb(223, 96, 166),
300px 0 0 -40px rgb(223, 96, 166),
400px 0 0 -40px rgb(223, 96, 166),
500px 0 0 -40px rgb(223, 96, 166);
}
to {
box-shadow: 100px 0 0 -40px rgb(223, 96, 166),
200px 0 0 -40px rgb(223, 96, 166),
300px 0 0 -40px rgb(223, 96, 166),
400px 0 0 -40px rgb(223, 96, 166);
}
}
@keyframes ball1 {
from {
transform: rotate(0deg);
}
to {
transform: rotate(-20deg);
}
}
@keyframes ball2 {
from {
transform: rotate(0deg);
}
to {
transform: rotate(20deg);
}
}
Css样式
.boxName {
display: flex;
width: 100%;
min-height: 100px;
margin-top: 20px;
}
.boxName .box {
width: 100px;
height: 100px;
background: rgba(0,0,0,0);
border-radius: 50%;
animation: boxFram 2s linear infinite;
}
.boxName .ball {
width: 100px;
height: 100px;
}
.boxName .ball p{
width: 100%;
height: 50%;
background: #e24f4f;
}
.boxName .ball p:nth-child(1) {
border-radius: 50px 50px 0 0;
animation: ball1 1s linear alternate infinite;
}
.boxName .ball p:nth-child(2) {
border-radius: 0 0 50px 50px;
animation: ball2 1s linear alternate infinite;
}