css3火箭发射特效
导读:CSS3火箭发射特效是一个十分酷炫的效果,它可以让我们实现一个火箭发射的场景,让网页变得非常的生动和有趣。.rocket{width: 150px;height: 300px;margin: 50px auto;position: rela...
CSS3火箭发射特效是一个十分酷炫的效果,它可以让我们实现一个火箭发射的场景,让网页变得非常的生动和有趣。
.rocket{
width: 150px;
height: 300px;
margin: 50px auto;
position: relative;
animation: launch 5s forwards;
animation-timing-function: cubic-bezier(0.450, 0.004, 0.210, 1.000);
}
.rocket .body{
width: 50px;
height: 80px;
position: relative;
margin: 0 auto;
background-color: #fff;
border-radius: 50%;
top: 130px;
}
.rocket .body:before{
width: 50px;
height: 70px;
content: "";
position: absolute;
background-color: #fff;
border-radius: 50% 50% 0 0;
bottom: 0;
}
.rocket .head{
width: 0;
height: 0;
border-style: solid;
border-width: 0 25px 50px 25px;
border-color: transparent transparent #ffffff transparent;
position: absolute;
left: 50%;
margin-left: -25px;
top: 50px;
}
.rocket .head:before{
width: 0;
height: 0;
border-style: solid;
border-width: 0 20px 40px 20px;
border-color: transparent transparent #cccccc transparent;
position: absolute;
left: -17px;
top: -3px;
}
.rocket .head:after{
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #cccccc;
position: absolute;
left: 50%;
margin-left: -4px;
top: -8px;
}
@keyframes launch{
0%{
transform: translate(0, 0) rotate(0);
}
30%{
transform: translate(0, -600px) rotate(0);
}
50%{
transform: translate(0, -800px) rotate(10deg);
}
70%{
transform: translate(0, -900px) rotate(0);
}
100%{
transform: translate(0, -1000px) rotate(-10deg);
}
}
以上代码就是实现CSS3火箭发射特效的关键,其中我们使用了关键帧动画和transform变换来实现火箭的飞行过程,可以让火箭有一个逐渐加速的效果,最终变得非常迅速。
相信通过这个例子,大家可以更好地理解CSS3动画的使用方法,并且可以运用到自己的项目当中,创造出更多炫酷的效果。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: css3火箭发射特效
本文地址: https://pptw.com/jishu/449767.html
