CSS3绘制弹球动画效果
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.box{
width:400px;
height: 400px;
border: 1px solid #ccc;
margin:30px auto;
position: relative;
}
/*绘制球*/
.box .ball{
width:140px;
height: 140px;
border-radius: 50%;
position: absolute;
top: 0px;
left: 50%;
background:-webkit-linear-gradient(top,#fff, #999);/*渐变色*/
box-shadow: inset 0 0 30px #999,inset 0 -15px 70px #999;/* 阴影*/
margin-left: -70px;
-webkit-animation: jump 2s ease-in-out infinite;/*链接球动画*/
z-index: 1;
}
/*利用伪类加强球的动画效果*/
.box .ball:after{
content: "";
display: block;
width: 70px;
height: 30px;
border-radius: 50%;
position: absolute;
top:10px;
left: 50%;
margin-left: -35px;
background: -webkit-linear-gradient(#fff,#ccc);
}
/*绘制阴影*/
.shadow{
width: 80px;
height: 60px;
border-radius: 50%;
position: absolute;
bottom: 0;
left: 50%;
margin-left: -40px;
background: rgba(20,20,20,.1);
box-shadow: 0 0 25px 20px rgba(20,20,20,.1);
transform: scaleY(.3);
-webkit-animation: shrink 2s ease-in-out infinite; /*链接阴影动画*/
}
/*球的动画*/
@-webkit-keyframes jump{
0%{
top:0;
-webkit-animation-timing-function:ease-in ;
}
65%{
top:240px;
height: 140px;
}
75%{
height:120px;
}
100%{
top:0;
height: 140px;
}
}
/*阴影的动画*/
@-webkit-keyframes shrink{
0%{
width:90px;
height: 60px;
-webkit-animation-timing-function: ease-in;
}
65%{
width: 10px;
height: 5px;
margin-left: -5px;
background: rgba(20,20,20,.3);
box-shadow: 0 0 25px 20px rgba(20,20,20,.3);
}
100%{
width: 90px;
height:60px;
background: rgba(20,20,20,.1);
box-shadow: 0 0 25px 20px rgba(20,20,20,.1);
}
}
</style>
</head>
<body>
<div class="box">
<div class="ball"></div>
<div class="shadow">
</div>
</div>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南