2D动画的一个场景应用

HTML代码

<section>
  <div class="stage">
    <div class="skyline"></div>
    <div class="beans"></div>
    <div class="ground back"></div>
    <div class="ground mid"></div>
    <div class="ground front"></div>
    <div class="dowEventCenter"></div>
    <div class="planetarium"></div>
    <div class="friendshipShell"></div>
    <div class="glockenspiel"></div>
    <!--汽球-->
    <div class="balloon"></div>
  </div>
</section>

CSS代码

body {margin:0; padding:0; background-color:#ddf5f7;}
/*-------- 天空背景以及动画 --------*/
.stage {
	position: relative;
	overflow: hidden;
	height: 600px;
	background: #ddf5f7;
	animation: beijing 20s infinite linear;
}
/* 背景色改变 */
@keyframes beijing{
	0%{
		background: lightblue;
	}
	25%{
		background: peachpuff;
	}
	50%{
		background: slateblue;
	}
	75%{
		background: darkgrey;
	}
	100%{
		background: lightblue;
	}
}
/*-------- 气球以及动画 --------*/
.balloon {
	position: absolute;
	z-index: 3;
	top: 5%;
	right: -157px;
	background: url(images/balloon.png) no-repeat no-repeat center;
	height: 227px;
	width: 157px;
	/* 先给需要的动画起个名字 在设置运动轨迹  infinite ease alternate 循环先慢在快轮流交换 */
	animation: qiqiu 20s infinite ease alternate;
}
/* 气球的动画效果用关键针@keyframes transform:rotate()旋转函数; */
 @keyframes qiqiu{
 	0%{
		right: -157px;
		transform: rotate(0deg);
	}
	25%{
		right: 25%;
		transform: rotate(30deg);
	}
	50%{
		right: 50%;
		transform: rotate(60deg);
	}

	75%{
		right: 75%;
		transform: rotate(30deg);
	}
	100%{
		right: 100%;
		transform: rotate(0deg);
	}
 }

/*-------- 城市场景图片 --------*/
.skyline {
	position: absolute;
	z-index: 5;
	width: 100%;
	bottom: 26%;
	background: url(images/skyline.png) repeat no-repeat;
	height: 147px;
}
.beans {
	position: absolute;
	z-index: 4;
	height: 201px;
	width: 88px;
	bottom: 30%;
	left: 50%;
	background: url(images/beans.png) no-repeat no-repeat;
}
.ground {
	position: absolute;
	width: 100%;
	bottom: 0;
}
.ground.front {
	z-index: 30;
	background: url(images/groundFront.png) repeat no-repeat center;
	height: 301px;
}
.ground.mid {
	z-index: 20;
	background: url(images/groundMid.png) repeat no-repeat;
	height: 299px;
}
.ground.back {
	z-index: 10;
	background: url(images/groundBack.png) repeat no-repeat center;
	height: 281px;
}
.dowEventCenter {
	position: absolute;
	z-index: 12;
	bottom: 20%;
	left: 5%;
	background: url(images/dowEventCenter.png) no-repeat no-repeat center;
	height: 236px;
	width: 524px;
}
.planetarium {
	position: absolute;
	z-index: 12;
	bottom: 18%;
	right: 10%;
	background: url(images/Planetarium.png) no-repeat no-repeat center;
	height: 285px;
	width: 347px;
}
.friendshipShell {
	position: absolute;
	z-index: 21;
	bottom: 18%;
	left: 20%;
	background: url(images/friendshipShell.png) no-repeat no-repeat center;
	height: 370px;
	width: 231px;
}
.glockenspiel {
	position: absolute;
	z-index: 11;
	bottom: 26%;
	right: 50%;
	background: url(images/Glockenspiel.png) no-repeat no-repeat center;
	height: 263px;
	width: 137px;
}

</style>

动画效果

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值