I've got a strange behavior when adding a CSS animation on top of the transition for a progress bar element: the transition just stops executing.
Not sure why I cannot have both, an initial animation and the transition when changing the element's width.
The whole thing looks like this:
HTML:
<div class="container">
<div class="bar"></div>
<div class="actions">
<button id="btnResize">Resize bar</button>
</div>
</div>
CSS:
.bar {
height: 3px;
width: 300px;
background-color: blue;
position: absolute;
transition: margin-left 0.5s ease-in-out, width 0.5s ease-in-out;
/*Transition breaks when I add the line below with animation rule*/
animation: progress-bar 1s 0.2s ease both;
}
@keyframes progress-bar {
0% {
width: 0
}
}
I have also created a JSBin to show the weirdness (https://jsbin.com/sufofitiri/edit?html,css,output)
Hopefully someone can give me a clue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…