To achieve the desired effect, nest two divs inside each other.
Alternatively, consider placing an image <img/>
within the container.
<div class="image-wrapper">
<div class="image-overlay"></div>
</div>
Below is the necessary CSS code:
(I assumed that all images have the same dimensions as those provided in your link. Alternatively, you can specify relative (in %) CSS properties.)
.image-wrapper {
position: relative;
width: 150px; /* Specify your image width */
height: 250px; /* Specify your image height */
background: url('path/to/your/image.png');
}
.image-overlay {
position: absolute;
z-index: 5; /* Ensure this value is one higher than the layer above */
width: 150px; /* Specify your image width */
height: 250px; /* Specify your image height */
display: none;
background-color: '#666666'; /* Choose your desired color */
opacity: 0.8;
}
Implement it with jQuery:
$('.image-wrapper').mouseenter(function() {
$(this).children('.image-overlay').fadeIn('fast');
}).mouseleave(function() {
$(this).children('.image-overlay').fadeOut('fast');
});
Remember to include vendor prefixes and filters for IE to ensure compatibility with older browsers. Additionally, deactivate features for very outdated versions of IE and Safari.