这是一款超酷 CSS3 鼠标悬停图片背景动画特效。该特效在鼠标悬停到图片上面的时候,通过 CSS3 帧动画和 filter 过滤器来制作非常炫酷的图片遮罩层动画效果。
在页面中引入下面的文件。
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
图片的 HTML 结果如下:
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-6">
<div class="box">
<img src="images/img-1.jpg" alt="">
<div class="box-content">
<h3 class="title">Steve Thomas</h3>
<span class="post">Web developer</span>
</div>
<ul class="icon">
<li><a href="#"><i class="fa fa-search"></i></a></li>
<li><a href="#"><i class="fa fa-link"></i></a></li>
</ul>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="box">
<img src="images/img-2.jpg" alt="">
<div class="box-content">
<h3 class="title">Kristina</h3>
<span class="post">Web designer</span>
</div>
<ul class="icon">
<li><a href="#"><i class="fa fa-search"></i></a></li>
<li><a href="#"><i class="fa fa-link"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
然后添加下面的 CSS 样式。
.box{
font-family: 'Fira Sans', sans-serif;
text-align: center;
overflow: hidden;
position: relative;
}
.box:before,
.box:after{
content: '';
background-color: rgba(255,255,255,0.7);
height: 25%;
width: 100%;
opacity: 0;
transform: translateX(-50%);
position: absolute;
left: 50%;
top: -100%;
transition: all 0.3s;
}
.box:after{ top: 100%; }
.box:hover:before{
transform: translateX(-50%) translateY(0);
top: 0;
}
.box:hover:after{
transform: translateX(-50%) translateY(0);
top: auto;
bottom: 0;
}
.box:hover:before,
.box:hover:after{
height: 50%;
opacity: 1;
animation: animate 0.5s linear;
}
.box img{
width: 100%;
height: auto;
}
.box .box-content{
width: 100%;
opacity: 0;
filter: blur(10px);
transform: translateX(-50%) translateY(-50%);
position: absolute;
top: 60%;
left: 50%;
z-index: 1;
transition: all 0.4s ease 0.1s;
}
.box:hover .box-content{
opacity: 1;
filter: blur(0);
top: 50%;
}
.box .title{
color: #4834d4;
font-size: 25px;
font-weight: 600;
text-transform: uppercase;
margin: 0;
}
.box .post{
color: #444;
font-size: 15px;
font-weight: 600;
text-transform: uppercase;
}
.box .icon{
padding: 0;
margin: 0;
list-style: none;
opacity: 0;
transform: translateX(-50%);
position: absolute;
left: 50%;
bottom: 10px;
z-index: 1;
transition: all 0.3s ease 0.3s;
}
.box:hover .icon{ opacity: 1; }
.box .icon li{ display: inline-block; }
.box .icon li a{
color: #fff;
background-color: #4834d4;
line-height: 25px;
height: 30px;
width: 30px;
border: 2px solid #fff;
border-radius: 50%;
box-shadow: 3px -3px 5px #555;
display: block;
transition: all 0.3s;
}
.box .icon li a:hover{
color: #4834d4;
background-color: #fff;
border-color: #4834d4;
}
@keyframes animate{
80%{ width: 90%; }
85%{ width: 95%; }
93%{ width: 85%; }
100%{ width: 100%; }
}
@media only screen and (max-width:990px){
.box{ margin-bottom: 30px; }
}
@media only screen and (max-width:479px){
.box .title{ font-size: 20px; }
}
演示地址 | 下载地址 |
专业提供WordPress主题安装、深度汉化、加速优化等各类网站建设服务,详询在线客服!