我一直在尝试在div内的图像上创建一个蒙版,但是蒙版不会覆盖div的整个区域(在中间留下空白)。一直试图解决它但无法找到解决方案。
这是我的进步 - http://jsfiddle.net/E2aWr/164/
.image-container {
width: 254px;
height: 280px;
margin: 10px;
float: left;
border: 5px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 0px 0px 5px #aaa;
cursor: default;
}
.image-container .mask, .image-container .content {
width: 250px;
height: 280px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.image-container img {
display: block;
position: relative;
}
.image-container a.info {
background:url('link.png') center no-repeat;
display: inline-block;
text-decoration: none;
padding:0;
text-indent:-9999px;
width:20px;
height:20px;
}
.effect .mask {
opacity: 0;
overflow:visible;
border:100px solid rgba(0, 0, 0, 0.7);
box-sizing:border-box;
transition: all 0.4s ease-in-out;
}
.effect a.info {
position:relative;
top:-10px;
/* Center the link */
opacity: 0;
transition: opacity 0.5s 0s ease-in-out;
}
.effect:hover .mask {
opacity: 1;
border:100px solid rgba(0, 0, 0, 0.7);
}
.effect:hover a.info {
opacity:1;
transition-delay: 0.3s;
}

<div class="image-container effect">
<img src="http://www.istudy.net.my/images/shop/manufacturer/resized/bc_220x280.jpg.png" />
<div class="mask">
<a href="#" class="info" title="Full Image">Full Image</a>
</div>
</div>
&#13;
答案 0 :(得分:2)
因为您的边框不是背景,请从mask
移除边框并添加背景
.effect:hover .mask {
opacity: 1;
background-color:rgba(0,0,0,0.7);
}
.effect .mask {
opacity: 0;
overflow:visible;
box-sizing:border-box;
transition: all 0.4s ease-in-out;
}
答案 1 :(得分:2)
我删除了此选择器.effect .mask
中的边框样式,并将边框样式更改为背景样式。
.image-container {
width: 254px;
height: 280px;
margin: 10px;
float: left;
border: 5px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 0px 0px 5px #aaa;
cursor: default;
}
.image-container .mask,
.image-container .content {
width: 250px;
height: 280px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.image-container img {
display: block;
position: relative;
}
.image-container a.info {
background: url('link.png') center no-repeat;
display: inline-block;
text-decoration: none;
padding: 0;
text-indent: -9999px;
width: 20px;
height: 20px;
}
.effect .mask {
opacity: 0;
overflow: visible;
box-sizing: border-box;
transition: all 0.4s ease-in-out;
}
.effect a.info {
position: relative;
top: -10px;
/* Center the link */
opacity: 0;
transition: opacity 0.5s 0s ease-in-out;
}
.effect:hover .mask {
opacity: 1;
}
.effect:hover a.info {
opacity: 1;
transition-delay: 0.3s;
}
.effect .mask {
opacity: 0;
overflow: visible;
box-sizing: border-box;
transition: all 0.4s ease-in-out;
}
.effect:hover .mask {
opacity: 1;
background: rgba(0, 0, 0, 0.7);
}
<div class="image-container effect">
<img src="http://www.istudy.net.my/images/shop/manufacturer/resized/bc_220x280.jpg.png" />
<div class="mask"> <a href="#" class="info" title="Full Image">Full Image</a>
</div>
</div>
希望它有所帮助。