css悬停图像和显示图标不显示

时间:2015-08-01 09:16:23

标签: html css css3

我使用css设计图书前端,需要使用css在悬停图片中显示搜索图标,如下所示:

.third-effect .mask {
    opacity: 0;
    overflow:visible;
    border:100px solid rgba(0, 0, 0, 0.7);
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
    -webkit-transition: all 0.4s ease-in-out;
    -moz-transition: all 0.4s ease-in-out;
    -o-transition: all 0.4s ease-in-out;
    -ms-transition: all 0.4s ease-in-out;
    transition: all 0.4s ease-in-out;
}
.third-effect a.info {
    position:relative;
    top:-10px;
    opacity: 0;
    -webkit-transition: opacity 0.5s 0s ease-in-out;
    -moz-transition: opacity 0.5s 0s ease-in-out;
    -o-transition: opacity 0.5s 0s ease-in-out;
    -ms-transition: opacity 0.5s 0s ease-in-out;
    transition: opacity 0.5s 0s ease-in-out;
}
.third-effect:hover .mask {
    opacity: 1;
    border:100px solid rgba(0, 0, 0, 0.7);
}
.third-effect:hover a.info {
    opacity:1;
    -moz-transition-delay: 0.3s;
    -webkit-transition-delay: 0.3s;
    -o-transition-delay: 0.3s;
    -ms-transition-delay: 0.3s;
    transition-delay: 0.3s;
}
.view {
    overflow: hidden;
    position: relative;
    text-align: center;
    cursor: default;
    width: 122px;
    height: 160px;
    box-shadow: -3px 3px 0 #ccc, -6px 6px 0 #999, -9px 9px 0 #ccc;
    -webkit-transition: all 0.15s ease;
}
.view:hover {
    box-shadow: -5px 5px 0 #ccc, -10px 10px 0 #999, -15px 15px 0 #ccc;
}
.view .mask, .view .content {
    width: 122px;
    height: 160px;
    position: absolute;
    overflow: hidden;
    top: 0;
    left: 0;
}
.view img {
    display: block;
    position: relative;
}
.view a.info {
    background:url("https://cdn3.iconfinder.com/data/icons/mixed-ui-icons-3/93/Untitled-124-128.png") center no-repeat;
    display: inline-block;
    text-decoration: none;
    padding:0;
    text-indent:-9999px;
    width:20px;
    height:20px;
}

但是在行动中我的搜索图标没有显示在悬停图像中。怎么解决这个问题?!

DEMO:http://jsfiddle.net/Sambora/o6nwamag/

1 个答案:

答案 0 :(得分:3)

试试这种风格吧。在你的风格中删除边框并使用背景颜色设置。

.third-effect .mask {
    opacity: 0;
    overflow:visible;
    background-color: rgba(0, 0, 0, 0.7);
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
    -webkit-transition: all 0.4s ease-in-out;
    -moz-transition: all 0.4s ease-in-out;
    -o-transition: all 0.4s ease-in-out;
    -ms-transition: all 0.4s ease-in-out;
    transition: all 0.4s ease-in-out;
}
.third-effect a.info {
    position:relative;
    top:40px;
    opacity: 0;
    -webkit-transition: opacity 0.5s 0s ease-in-out;
    -moz-transition: opacity 0.5s 0s ease-in-out;
    -o-transition: opacity 0.5s 0s ease-in-out;
    -ms-transition: opacity 0.5s 0s ease-in-out;
    transition: opacity 0.5s 0s ease-in-out;
}
.third-effect:hover .mask {
    opacity: 1;
    
}
.third-effect:hover a.info {
    opacity:1;
    -moz-transition-delay: 0.3s;
    -webkit-transition-delay: 0.3s;
    -o-transition-delay: 0.3s;
    -ms-transition-delay: 0.3s;
    transition-delay: 0.3s;
}
.view {
    overflow: hidden;
    position: relative;
    text-align: center;
    cursor: default;
    width: 122px;
    height: 160px;
    box-shadow: -3px 3px 0 #ccc, -6px 6px 0 #999, -9px 9px 0 #ccc;
    -webkit-transition: all 0.15s ease;
}
.view:hover {
    box-shadow: -5px 5px 0 #ccc, -10px 10px 0 #999, -15px 15px 0 #ccc;
}
.view .mask, .view .content {
   height: 160px;
    left: 0;
    overflow: hidden;
    position: absolute;
    top: 0;
    width: 122px;
}
.view img {
    display: block;
    position: relative;
}
.view a.info {
    background: rgba(0, 0, 0, 0) url("https://cdn3.iconfinder.com/data/icons/mixed-ui-icons-3/93/Untitled-124-128.png") no-repeat scroll center center / 100% auto;
    display: inline-block;
    height: 20px;
    padding: 20px;
    text-decoration: none;
    text-indent: -9999px;
    width: 20px;
}
<div class="view third-effect">
    <img src="http://i.imgur.com/nbynS1m.jpg" />
    <div class="mask">	<a href="#" class="info" title="Full Image">Full Image</a>

    </div>
</div>