css大雁飞行特效
时间: 2023-07-23 12:15:10 浏览: 48
好的,以下是一种实现CSS大雁飞行特效的方法:
HTML代码:
```
<div class="geese">
<div class="geese-shape"></div>
<div class="geese-shape"></div>
<div class="geese-shape"></div>
<div class="geese-shape"></div>
</div>
```
CSS代码:
```
.geese {
position: relative;
width: 100%;
height: 200px;
overflow: hidden;
}
.geese-shape {
position: absolute;
width: 100px;
height: 20px;
border-radius: 10px;
background-color: #f6c90e;
box-shadow: 0 0 10px 5px rgba(255, 255, 255, 0.3);
transform: rotate(-30deg);
animation: fly 5s linear infinite;
}
.geese-shape:nth-child(2) {
left: 20%;
top: 50%;
transform: rotate(-20deg);
animation-delay: 0.25s;
}
.geese-shape:nth-child(3) {
left: 40%;
top: 25%;
transform: rotate(-10deg);
animation-delay: 0.5s;
}
.geese-shape:nth-child(4) {
left: 60%;
top: 75%;
transform: rotate(10deg);
animation-delay: 0.75s;
}
@keyframes fly {
0% {
transform: rotate(-30deg) translateX(0);
}
100% {
transform: rotate(-30deg) translateX(-150%);
}
}
```
其中,.geese表示大雁的群体,通过设置它的宽度、高度和overflow属性,实现画布的效果。.geese-shape表示每只大雁,通过设置它的大小、圆角、颜色、投影、旋转角度和动画效果,实现大雁的效果。通过nth-child选择器,实现每只大雁在画布上的位置和动画的延迟时间。通过设置关键帧,实现大雁沿着一条直线飞行的效果。
希望以上内容能够对您有所帮助!