代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="new_file.css"/>
</head>
<body>
<figure>
<figcaption>大海</figcaption>
<div class="a1" >
<img src="img/大海.png" height="200px" width="200px">
</div>
</figure>
<figure>
<figcaption>花田</figcaption>
<div>
<img class="a2" src="img/花田.png" height="200px" width="200px">
</div>
</figure>
<figure>
<figcaption>汽车</figcaption>
<div class="a3">
<img src="img/汽车.png" height="200px" width="200px">
</div>
</figure>
<figure>
<figcaption>邮轮</figcaption>
<div>
<img class="a4" src="img/邮轮.png" height="200px" width="200px">
</div>
</figure>
</body>
</html>
CSS
body{
background-color:#222222;
}
figure{
float: left;
text-align: center;
color:white;
}
div{
margin-top: 20px;
height: 200px;
width: 200px;
overflow: hidden;
border: white solid 8px;
border-radius: 10px;
transition: all 0.5s ease;
}
.a1{
transition: all 0.5s ease;
}
.a1:hover{
border-radius: 150px;
}
.a2{
display: block;
transition: all 0.5s ease;
}
.a2:hover{
height: 300px;
width: 300px;
}
.a3{
transition: all 0.5s ease;
}
.a3:hover{
transform:rotate(20deg);
}
.a4{
transition: all 1s ease;
}
.a4:hover{
opacity: 0.5;
}
div:hover{
box-shadow: 10px 10px 50px #aaaaaa;
}
效果:
初始效果:
圆角边框:
图片放大:
图片旋转:
亮度变暗:
解析:
在第一个效果中,就是改变了边框的border-raduis属性,而且设置了一个过渡效果。
.a1{
transition: all 0.5s ease;
}
.a1:hover{
border-radius: 150px;
}