I'm trying to brighten an image (from 20% to 100%) when you hover over it, capping the brightness at 100% after the animation and gradually returning it's brightness to 20% when the mouse is not hovering there.
I tried to use animation-fill-mode: forwards; but it doesn't seem to have any effect, the image keeps resetting or becaming completely white after the animation ended, if i move the mouse away it resets to 20% brightness immediately.
<img class="fading" src="/uploads/2015/09/test.jpg"/>
@keyframes brightup{
0% {-webkit-filter: brightness(20%);
}
25% {-webkit-filter: brightness(25%);
}
50% {-webkit-filter: brightness(50%);
}
75% {-webkit-filter: brightness(75%);
}
100% {-webkit-filter: brightness(100%);
}
}
img.fading {
-webkit-filter: brightness(20%);
}
img.fading:hover {
animation-name: brightup;
animation-duration: 2s;
animation-timing-function: linear;
animation-delay: 500ms;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}