纯css3用图片写出的游戏动画

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style type="text/css">
			#d1{
				width: 300px;
				height: 200px;
				/* border: 1px solid #cccc; */
				/* 背景图片 */
				background-image: url(img/mingr.png);
				/* 背景图片大小 */
				/* 注意:元素宽度百分比 */
				background-size: auto;
				/* 背景图片的位置 */
				/* background-position: x ,y; steps阶梯型*/
				/* animation: mr 2s steps(16) infinite; */
				position: absolute;
				left: 0;
				top: 0;
			}
			@keyframes mr{
				from{
					background-position: 0 0;
				}
				to{
					background-position: 0 3072px;
				}
			}
			#lxw:checked~#d1{
				animation: mr 2s steps(16) infinite;
				/* 层级,默认的是0,最底下的会把高的覆盖 */
				z-index: 1;
			}
			#d2{
				width: 300px;
				height: 200px;
				/* border: 1px solid #cccc; */
				background-image: url(img/qianniao.png);
				background-size:960px auto;
				animation: qniao 3s steps(18) infinite;
				position: absolute;
				left: 0;
				top: 0;
			}
			@keyframes qniao{
				from{
					background-position: 0 0;
				}
				to{
					background-position: 0 -4416px;
				}
			}
			.main{
				width: 600px;
				height: 400px;
				margin: 0 auto;
				border: 1px solid #cccc;
				position: relative;
			}
			label{
				display: inline-block;
				width:200px ;
				height: 40px;
				font-size: 20px;
				color: #ccc;
				border: 1px solid #ccc;
				border-radius: 10px;
				text-align: center;
				line-height:40px ;
				cursor: pointer;
			}
		</style>
	</head>
	<body>
		<div class="main">
			<input type="checkbox" name="" id="lxw" value="" hidden="hidden"/>
			<div id="d1"></div>
			<div id="d2"></div>
		</div>
		<label for="lxw">点击:鸣人放大招</label>
	</body>
</html>

纯css3用图片写出的游戏动画

上一篇:设置TABLE表格边框为单实线


下一篇:CSS动画