效果图:
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>过渡与变形的综合应用</title>
<style type="text/css">
body{
background-color: black;
}
.boxone,.boxtwo,.boxthree,.boxfour{
width: 200px;
height: 250px;
text-align: center;
color: white;
float: left;
margin: 50px 10px;
}
.boxone div,.boxtwo div,.boxthree div,.boxfour div{
width: 150px;
height: 150px;
border: 7px solid white;
overflow: hidden;
margin: 20px auto;
border-radius: 10px;
transition: all 1s linear;
}
.boxone div{
background-image: url(img/one.jpg);
}
.boxtwo div{
background-image: url(img/two.jpg);
background-size: 100% 120%; /*先使背景图片完全覆盖盒子,设置初始大小*/
background-repeat: no-repeat;
}
.boxthree div{
background-image: url(img/three.jpg);
}
.boxfour div{
background-image: url(img/four.jpg);
}
.boxone div:hover{
border-radius:50%;
box-shadow: 0 0 10px white;
}
.boxtwo div:hover{
background-size: 200% 240%;/*放大2倍*/
box-shadow: 0 0 10px white;
}
.boxthree div:hover{
transform: rotate(360deg);
box-shadow: 0 0 10px white;
}
.boxfour div:hover{
filter:grayscale(1); /*滤镜属性*/
box-shadow: 0 0 10px white;
}
</style>
</head>
<body>
<div class="boxone">
<span>SHAPE</span>
<div></div>
</div>
<div class="boxtwo">
<span>DISPLACEMENT</span>
<div></div>
</div>
<div class="boxthree">
<span>POSITION</span>
<div></div>
</div>
<div class="boxfour">
<span>COLOR</span>
<div></div>
</div>
</body>
</html>