原 CSS3学习第11篇——综合练习弹跳滚动的小球

目标:

一个小球从空中落下,然后弹起、落下、弹起落下……,向右滚动,最后停止,根据受力情况的不同进行缩放变形。

代码:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>css3 弹跳的小球</title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		html,body{
			width: 100%;
			height: 100%;
		}
		.box{
			width: 100%;
			height: 100%;
			background-color: black;
			position: relative;
			perspective: 1000px;
		}

		.ball{
			width: 100px;
			height: 100px;
			border-radius: 50%;
			background:  -webkit-radial-gradient(25% 25%,farthest-corner,#59F3F1,black);
			position: absolute;
			z-index: 99;
			top: 100px;
			left: 300px;
			text-align:center;
			line-height: 100px;
			font-size: 40px;
			animation:run 10s ease-in-out 1 forwards 0.5s;
		}

		.earth{
			width: 100%;
			height:600px;
			position: fixed;
			top:400px;
			left: 50px;
			background-color:white;
			transform-style: preserve-3d;
			transform: rotateX(90deg) translateY(-300px);
		}

		@keyframes run{
			0%{
				transform: translateY(0px);
			}

			7%{
				transform: translateY(400px) scaleX(1.2);
			}

			15%{
				transform: translateY(50px) scaleY(1.2);
			}

			22%{
				transform: translateY(400px) scaleX(1.1);
			}

			31%{
				transform: translateY(100px) scaleY(1.1);
			}

			40%{
				transform: translateY(400px) scaleX(1.05);;
			}

			50%{
				transform: translateY(200px) scaleY(1.05);
			}

			60%{
				transform: translateY(400px);
			}

			70%{
				transform: translateY(300px);
			}

			85%{
				transform: translateY(400px);
			}

			100%{
				transform: translateY(460px) translateX(400px) rotateZ(180deg) ;
			}
		}
	</style>
</head>
<body>
	<div class="box">
		<div class="ball">^_^</div>
		<div class="earth"></div>
	</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值