Exploring a tutorial on creating hover effects for images, where text appears and the background darkens. The tutorial can be found here.
Encountering an issue with the hover effect - when hovering over the image, I want the entire image to darken and be covered fully. Setting the height of ul.img-list li to 100% only covers the text area, adjusting it to the image's height causes problems when the window size changes. Is there something I'm overlooking?
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>Hello@!</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;
}
View my jsfiddle here - http://jsfiddle.net/f32kn4h5/