I am trying to create a hover effect where a caption displayed over an image fades in with a background color change. I have attempted to use transitions but they do not seem to work for block elements.
For the code and JSFiddle, please visit this link.
My HTML:
<div class="box">
<img src="http://bit.ly/1G1Pcbz" alt="coding">
<div class="overlay">
This is my caption overlay.
</div>
</div>
CSS I'm using:
img {
height: auto;
max-width: 100%;
}
.box {
position: relative;
display: block;
width: 200px;
height: 117px;
background: #ccc;
transition: all 0.5s ease-in-out;
}
.overlay {
display: none;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: red;
z-index: 9999;
}
.box:hover .overlay {
display: block;
}