css3中的transition的应用案例一
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>traansform的图片移动的案例</title>
<style>
*{
margin:0 ;padding:0;}
div{
background: url(day16/案例图片/bg2.jpg) no-repeat ;
background-size: 500px 394px;
}
.box1{
width: 500px;
height: 394px;
margin: 100px auto;
/* border: solid red 1px; */
position: relative;
overflow: hidden;
}
.box1 img:nth-child(1){
border: black solid 10px;
margin: 50px 80px;
transition: 1s;
}
.box1 img:nth-child(2){
position: absolute;
top: 20px;
right: -140px;
transition: 1s;
}
.box1 img:nth-child(3){
position: absolute;
right: -140px;
top: 143px;
transition: 1s 0.2s;
}
.box1 img:nth-child(4){
position: absolute;
right: -140px;
top: 295px;
transition: 1s 0.3s;
}
.box1 img:nth-child(5){
position: absolute;
bottom: -140px;
left: 200px;
transition: 1s 0.4s;
}
.box1 img:nth-child(6){
position: absolute;
bottom: -140px;
left: 50px;
transition: 1s 0.5s;
}
.box1 img:first-child:hover{
transform: scale(0.8);
}
.box1 img:first-child:hover ~.right{
transform: translateX(-150px);
}
.box1 img:first-child:hover ~.bottom{
transform: translateY(-150px);
}
</style>
</head>
<body>
<div class="box1">
<img src="day16/案例图片/con1-1.jpg" alt="s">
<img src="day16/案例图片/con1-2.jpg" alt="s" class="right">
<img src="day16/案例图片/con1-3.jpg" alt="s" class="right">
<img src="day16/案例图片/con1-4.jpg" alt="s" class="right">
<img src="day16/案例图片/con2-6.jpg" alt="s"class="bottom">
<img src="day16/案例图片/con1-6.jpg" alt="s"class="bottom">
</div>
<div class="box1">
<img src="day16/案例图片/con2-1.jpg" alt="">
<img src="day16/案例图片/con2-2.jpg" alt="" class="right">
<img src="day16/案例图片/con2-3.jpg" alt="" class="right">
<img src="day16/案例图片/con2-4.jpg" alt="" class="right">
<img src="day16/案例图片/con2-5.jpg" alt=""class="bottom">
<img src="day16/案例图片/con2-6.jpg" alt=""class="bottom">
</div>
<div class="box1">
<img src="day16/案例图片/con3-1.jpg" alt="">
<img src="day16/案例图片/con3-2.jpg" alt="" class="right">
<img src="day16/案例图片/con3-3.jpg" alt="" class="right">
<img src="day16/案例图片/con3-4.jpg" alt="" class="right">
<img src="day16/案例图片/con3-5.jpg" alt=""class="bottom">
<img src="day16/案例图片/con3-6.jpg" alt=""class="bottom">
</div>
</body>
</html>