代码如下所示:
<!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>
实现效果如下所示: