0
我正在关注悬停效果的教程,其中文本弹出并且背景变黑。教程here。CSS将鼠标悬停在图片上的文字
我有一个悬停效果的小问题,当鼠标悬停在图像上时,我希望图像变暗并覆盖整个图像,当我将ul.img-list li设置为高度100%它只占用了文本的100%,我可以将高度设置为图像的高度,但当高度根据窗口大小而变化时,将无法正确覆盖。我错过了什么吗?
HTML:
<div class="column large-6">
<ul class="img-list">
<li>
<a href="#">
<img src="https://www.ricoh.com/r_dc/r/r8/img/sample_08.jpg" />
<span class="text-content">
<span>[email protected]!</span>
</span>
</a>
</li>
</ul>
CSS:
ul.img-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.img-list li {
display: inline-block;
height: 100%;
margin: 0 1em 1em 0;
position: relative;
width: 100%;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 150px;
left: 0;
position: absolute;
top: 0;
width: 150px;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 150px;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
这里是我的jsfiddle - http://jsfiddle.net/f32kn4h5/
这个问题是相关的,也许它会帮助.. http://stackoverflow.com/questions/18322548/black-transparent -overlay-on-image-hover-with-only-css – 2015-04-01 15:58:17
这是非常有帮助的,加到最爱,谢谢! – TJXStyles 2015-04-01 16:03:29
小提琴似乎适合我。 Nevermind不,它不 – Steve 2015-04-01 16:09:19