CSS3实现球的自由落体

代码如下所示:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8">
	<title>HTML5+CSS3练习</title>
	<script src="jquery-1.8.3.min.js"></script>
</head>
<body>
	<fieldset style="height:550px;">
		<legend>自由落体</legend>
		北京时间:<span class="time"></span>
		<figure class="circle"></figure>
		<figure class="shadow"></figure>
		<style>
		  @keyframes circle{
		  	0%,100%{
		  		margin-top:20px;
		  	}
		  	2%{
		  		margin-top:20px;
		  	}
		  	98%{
		  		margin-top:20px;
		  	}
		  	48%{
		  		margin-top: 300px;
		  	}
		  	52%{
		  		margin-top: 300px;
		  	}
		  }

		  .circle{
          	height:200px;
          	width:200px;
          	margin:20px auto 0px;
          	border-radius: 50%;
          	position: relative;
          	z-index: 10;
          	background-image: radial-gradient(circle at 70px 80px,#39c,#000);
          	animation:circle 2s ease-in infinite alternate;
          }

		  @keyframes shadow{
		  	0%,100%{
		  		height: 50px;
		  		width: 50px;
		  		margin-left: -25px;
		  		margin-top: 40px;
		  		background-color:rgba(0,0,0,0.5);
		  	}
		  	2%{
		  		height: 50px;
		  		width: 50px;
		  		margin-left: -25px;
		  		margin-top: 40px;
		  		background-color:rgba(0,0,0,0.5);
		  	}
		  	98%{
		  		height: 50px;
		  		width: 50px;
		  		margin-left: -25px;
		  		margin-top: 40px;
		  		background-color:rgba(0,0,0,0.5);
		  	}
		  	48%{
		  		height: 170px;
		  		width: 170px;
		  		margin-left: -85px;
		  		margin-top: -10px;
		  		background-color: rgba(0,0,0,0.8);
		  	}
		  	52%{
		  		height: 170px;
		  		width: 170px;
		  		margin-left: -85px;
		  		margin-top: -10px;
		  		background-color: rgba(0,0,0,0.8);
		  	}
		  }
          
          .shadow{
          	transform-style:preserve-3d;
          	transform:rotate3d(1,0,0,80deg);
          	animation:shadow 2s ease-in infinite alternate;
            border-radius: 50%;
            position: absolute;
            top: 470px;
            left: 50%;
          }
		</style>
		<script>
        $(function(){
        	time();
        	window.setInterval(time,1000);

        });        
        var time=function(){
        	var date=new Date();
        	$(".time").text(date.toLocaleString());
        }
		</script>
	</fieldset>
	
</body>
</html>

实现效果如下所示:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值