JSFiddle - React, Tailwind, and code Playground
HTML
<div class="images-container">
<img class="normal" src="http://lorempixel.com/400/200/animals/9/">
<img class="hover" src="http://lorempixel.com/400/200/animals/10/">
</div>
CSS
div{
position: relative;
width: 400px;
height: 200px;
}
div > img{
display: block;
width: 400px;
height: 200px;
position: absolute;
/* transitions */
-webkit-transition: all .4s ease;
-moz-transition: all .4s ease;
-ms-transition: all .4s ease;
-o-transition: all .4s ease;
transition: all .4s ease;
}
/* solution 2: css2 solution, hide/show elements by class */
div > img.normal{
filter: alpha(opacity=100); /* IE stuff */
opacity: 1;
z-index: 2;
}
div > img.hover{
filter: alpha(opacity=0); /* IE stuff */
opacity: 0;
z-index: 1;
}
/* hover */
div:hover > img.normal{
filter: alpha(opacity=0);
opacity: 0;
z-index: 1;
}
div:hover > img.hover{
filter: alpha(opacity=100);
opacity: 1;
z-index: 2;
}