I have a keyframes animation for a bar graph. The widths are set inline with style attributes (coming from Razor) and the animation works fine but I'm not able to delay it's start. Using the delay property of animation shows all bars in the graph, then after 1s they hide and animate. My goal is to not show the green bars at all until the animation runs.
I've tried animating opacity, toggling the animation css with jQuery and not displaying the bars until the animation runs but nothing seems to work.
Any ideas?
<div class="bar" style="width: 80%"></div>
The CSS
@keyframes graph-bar {
0% {
width: 0;
}
}
.bar {
background-color: green;
height: 20px;
cursor: pointer;
animation: graph-bar 1s ease-out;
}
UPDATE
@Ankith's solution worked well and pointed me in the right direction, but I was able to use jQuery so I'm going with this shorter version. Apparently I just needed to pass the duration to both show() and hide(). I also updated the tags on this post because I hadn't originally included jQuery.
$('.bar').hide(0).delay(2000).show(0);