两款鼠标hover图片CSS3动画特效

当前位置:主页 > CSS3库 > CSS3动画 > 两款鼠标hover图片CSS3动画特效
两款鼠标hover图片CSS3动画特效
分享:

    插件介绍

    这是两款效果非常炫酷的鼠标hover图片CSS3动画特效。特效中在鼠标hover图片的时候,使用transition和transform来制作图片说明文本和图标的CSS3动画特效。

    浏览器兼容性

    浏览器兼容性
    时间:03-25
    阅读:
简要教程

这是两款效果非常炫酷的鼠标hover图片CSS3动画特效。特效中在鼠标hover图片的时候,使用transitiontransform来制作图片说明文本和图标的CSS3动画特效。

使用方法

示例中使用了bootstrap和fontawesome字体图标,需要在页面中引入相关文件。

<link href="path/to/css/bootstrap.min.css" rel="stylesheet">
<link href="path/to/css/font-awesome.min.css" rel="stylesheet">     
                
鼠标hover图片效果-1

第一个鼠标hover图片的效果如下图:

鼠标hover图片特效-1

该效果的HTML结构如下:

<div class="container">
    <div class="row">
        <div class="col-md-4 col-sm-6">
            <div class="box">
                <img src="img/1.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-1</h3>
                    <span class="post">未来科技</span>
                    <ul class="social">
                        <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                        <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="#"><i class="fa fa-instagram"></i></a></li>
                        <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="col-md-4 col-sm-6">
            <div class="box">
                <img src="img/2.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-2</h3>
                    <span class="post">未来科技</span>
                    <ul class="social">
                        <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                        <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="#"><i class="fa fa-instagram"></i></a></li>
                        <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="col-md-4 col-sm-6">
            <div class="box">
                <img src="img/3.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-3</h3>
                    <span class="post">未来科技</span>
                    <ul class="social">
                        <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                        <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                        <li><a href="#"><i class="fa fa-instagram"></i></a></li>
                        <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>                  
                

制作该动画特效的CSS3代码如下:

.box{
    text-align: center;
    overflow: hidden;
    color: #fff;
    position: relative;
}
.box:after{
    content: "";
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.08) 69%, rgba(0, 0, 0, 0.76) 100%);
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.5s ease 0s;
}
.box:hover:after{
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.01) 0%, rgba(0, 0, 0, 0.09) 11%, rgba(0, 0, 0, 0.12) 13%, rgba(0, 0, 0, 0.19) 20%, rgba(0, 0, 0, 0.29) 28%, rgba(0, 0, 0, 0.29) 29%, rgba(0, 0, 0, 0.42) 38%, rgba(0, 0, 0, 0.46) 43%, rgba(0, 0, 0, 0.53) 47%, rgba(0, 0, 0, 0.75) 69%, rgba(0, 0, 0, 0.87) 84%, rgba(0, 0, 0, 0.98) 99%, rgba(0, 0, 0, 0.94) 100%);
}
.box img{
    width: 100%;
    height: auto;
}
.box .box-content{
    width: 100%;
    padding: 20px;
    margin-bottom: 20px;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
}
.box .title{
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 0 10px 0;
    transform: translateY(145px);
    transition: all 0.4s cubic-bezier(0.13, 0.62, 0.81, 0.91) 0s;
}
.box .post{
    display: block;
    padding: 8px 0;
    font-size: 15px;
    transform: translateY(145px);
    transition: all 0.4s cubic-bezier(0.13, 0.62, 0.81, 0.91) 0s;
}
.box:hover .title,
.box:hover .post{
    transform: translateY(0);
}
.box .social{
    list-style: none;
    padding: 0 0 5px 0;
    margin: 40px 0 25px;
    opacity: 0;
    position: relative;
    transform: perspective(500px) rotateX(-90deg) rotateY(0deg) rotateZ(0deg);
    transition: all 0.6s cubic-bezier(0, 0, 0.58, 1) 0s;
}
.box:hover .social{
    opacity: 1;
    transform: perspective(500px) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
}
.box .social:before{
    content: "";
    width: 50px;
    height: 2px;
    background: #fff;
    margin: 0 auto;
    position: absolute;
    top: -23px;
    left: 0;
    right: 0;
}
.box .social li{
    display: inline-block;
}
.box .social li a{
    display: block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    background: #6d3795;
    font-size: 20px;
    color: #fff;
    margin-right: 10px;
    transition: all 0.3s ease 0s;
}
.box .social li a:hover{
    background: #bea041;
}
.box .social li:last-child a{
    margin-right: 0;
}
@media only screen and (max-width:990px){
    .box{ margin-bottom: 30px; }
}
                
鼠标hover图片效果-2

第二个鼠标hover图片的效果如下图:

鼠标hover图片特效-2

该效果的HTML结构如下:

<div class="container">
    <div class="row">
        <div class="col-md-4 col-sm-6">
            <div class="box">
                <img src="img/1.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-1</h3>
                    <span class="post">未来科技</span>
                </div>
                <ul class="social">
                    <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="img/2.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-2</h3>
                    <span class="post">未来科技</span>
                </div>
                <ul class="social">
                    <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="img/3.jpg">
                <div class="box-content">
                    <h3 class="title">超现实作品-3</h3>
                    <span class="post">未来科技</span>
                </div>
                <ul class="social">
                    <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>                  
                

制作第二种鼠标hover图片动画特效的CSS3代码如下:

.box{
    text-align: center;
    overflow: hidden;
    position: relative;
}
.box:after{
    content: "";
    width: 100%;
    height: 100%;
    background-color: rgba(0,63,91,0.6);
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: all 0.5s ease 0s;
}
.box:hover:after{
    opacity: 1;
}
.box img{
    width: 100%;
    height: auto;
}
.box .box-content{
    width: 100%;
    background: #255773;
    padding: 10px 0;
    color: #d5f7ff;
    position: absolute;
    bottom: -100%;
    left: 0;
    z-index: 1;
    transition: all 0.5s ease 0s;
}
.box:hover .box-content{
    bottom: 0;
}
.box .title{
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}
.box .post{
    display: block;
    font-size: 15px;
    text-transform: capitalize;
}
.box .social{
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}
.box .social li{
    display: inline-block;
    margin-right: 7px;
    position: relative;
    transform: translateY(-100px);
    transition: all 0.5s ease 0s;
}
.box:hover .social li:first-child{
    transition-delay: 0.5s;
}
.box:hover .social li:last-child{
    transition-delay: 0.8s;
}
.box .social li:before{
    content: "";
    position: absolute;
    width: 1px;
    height: 50px;
    background: #f1e7c3;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
}
.box:hover .social li{
    transform: translateY(0);
}
.box .social li a{
    display: block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    background: #f1e7c3;
    font-size: 20px;
    font-weight: 700;
    color: #003f5b;
    margin-top: 50px;
    opacity: 1;
    transition: all 0.3s ease 0s;
}
.box:hover .social li a{
    opacity: 1;
}
.box .social li a:hover{
    background: #ff9420;
    color: #fff;
}
@media only screen and (max-width:990px){
    .box{ margin-bottom: 30px; }
}