I am currently working on a CSS3 effect that triggers on mouseover. This effect involves animating an inner div by scaling it endlessly.
Everything is functioning correctly, however, when I move the mouse away, the div abruptly returns to its original size. I am looking to incorporate a smooth transition to scale the div back to its original size.
I have already explored the suggestions from this post: Make CSS Hover state remain after "unhovering" Unfortunately, the provided code did not work for me. I suspect that my issue may be related to the "infinite" loop of the scale effect.
The desired outcome I am aiming for is that when the mouse moves out, the image smoothly transitions back to its original size.
Below is the code: https://jsfiddle.net/9dtqpsLa/1/
CSS
@keyframes imageZoom{
0% { transform: scale(1); }
50% { transform: scale(1.24); }
100% { transform: scale(1);}
}
@-moz-keyframes imageZoom{
0% { -moz-transform: scale(1);}
50% { -moz-transform: scale(1.24); }
100% { -moz-transform: scale(1); }
}
@-webkit-keyframes imageZoom{
0% { -webkit-transform: scale(1); }
50% {-webkit-transform: scale(1.24); }
100% { -webkit-transform: scale(1); }
}
@-ms-keyframes imageZoom{
0% { -ms-transform: scale(1); }
50% { -ms-transform: scale(1.24); }
100% { -ms-transform: scale(1); }
}
.article:hover .imageWrapper {
animation: imageZoom linear 10s;
animation-iteration-count: infinite;
-webkit-animation: imageZoom linear 10s;
-webkit-animation-iteration-count: infinite;
-moz-animation: imageZoom linear 10s;
-moz-animation-iteration-count: infinite;
-ms-animation: imageZoom linear 10s;
-ms-animation-iteration-count: infinite;
transform-origin: 50% 80%;
}
.article {
background-color: #e6e6e6;
overflow: hidden;
width: 300px;
height: 300px;
}
.imageWrapper {
background-image: url('http://www.astutegraphics.com/images/blog/tutorials/widthscribe_patterns_18_mar_2013/floral-seamless-pattern.png');
width: 300px;
height: 300px;
}
HTML
<div class="article">
<div class="imageWrapper">
</div>
</div>
Your assistance would be greatly appreciated.
Thank you very much