I'm making a little countdown bar with a css transition:
.livebar {
background-color: black;
transition: width 15s linear;
width: 100%;
height: 5px;
}
This code doesn't work (in Chrome), in the sense that there is no transition. The width goes to 0 immediately:
$("#barbag").append("<div class='livebar'></div>");
$(".livebar").css("width", "0");
...but this code works beautifully:
$("#barbag").append("<div class='livebar'></div>");
setTimeout(function(){$(".livebar").css("width", "0")}, 1);
Also, doing the two statements separately in the console works, but pasting in both fails.
It seems like Chrome needs some time after creating the .livebar
div to make the transition "active". Is this a known bug, or am I doing something wrong, or is something entirely different going on?