css实现盾牌的动画效果

直接上代码:用伪类选择器去选择每个图片,再进行2d动画的实现

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			body{
				background: blueviolet;
			}
			.div1{
				width: 450px;
				height: 500px;
				/*border: 1px solid black;*/
				margin: 100px auto;
			}
			.div1 img:nth-child(1){
				transform: translate(-100px,50px) rotate(45deg);
				transition: all 2s linear;
			}
			.div1 img:nth-child(2){
				transform: translate(-300px,180px) rotate(145deg);
				transition: all 2s linear;
			}
			.div1 img:nth-child(3){
				transform: translate(200px,-40px) rotate(245deg);
				transition: all 2s linear;
			}
			.div1 img:nth-child(4){
				transform: translate(150px,50px) rotate(45deg);
				transition: all 2s linear;
			}
			.div1:hover img{
				transform: translate(0,0) rotate(0deg);
				
			}
		</style>
	</head>
	<body>
		<div class="div1">
			<img src="img/shield_1_01.png" />
			<img src="img/shield_1_02.png" />
			<img src="img/shield_1_03.png" />
			<img src="img/shield_1_04.png" />
			<img src="img/shield_1_05.png" />
			<img src="img/shield_1_06.png" />
			<img src="img/shield_1_07.png" />
			<img src="img/shield_1_08.png" />
			<img src="img/shield_1_09.png" />
		</div>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/yilv12123/article/details/83956505
今日推荐