Hello, readers.
This blog post will tell you how to get one image in place of the other on hover. The height and width of the images are 100% and the position is given absolute. Due to this, one image appears behind the other. The second thing to do is changing the opacity of the top image on hover.
HTML :
<div id="parentdiv">
<img class="bottom" src="two.jpg" />
<img class="top" src="one.jpg" />
</div>
CSS :
#parentdiv{
position:relative;
height:281px;
width:450px;
margin:0 auto;
}
img{
border: 0 none;
height: 100%;
width: 100%;
vertical-align: middle;
}
#parentdiv img{
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.top{
cursor: pointer;
}
#parentdiv img.top:hover{
opacity:0;
}
0 Comment(s)