I have some CSS animation with keyframes on my page for fadein/out elements. The problem is that the fadeout animations are shown when i load the page.
HTML:
<button class="toggle-good">Toggle display</button>
<p class="box">I move nicely!</p>
CSS:
.box {
height: 0;
opacity: 0;
animation: FadeOut 1s ease-in-out;
}
.box.active {
height: initial;
opacity: 1;
animation: FadeIn 1s ease-in-out;
}
@keyframes FadeIn {
0% {
opacity: 0;
height: initial;
}
100% {
opacity: 1;
height: initial;
}
}
@keyframes FadeOut {
0% {
opacity: 1;
height: initial;
}
99% {
opacity: 0;
height: initial;
}
100% {
height: 0;
opacity: 0;
height: 0;
}
}
JS:
$('button').on('click', function(e) {
$(this).siblings('.box').toggleClass('active');
})
Working example: http://codepen.io/MickL/pen/LkvWaA