Trying to grow a pseudo-element line from left to right to full width of it's container then shrinking it from right to left to zero width. Side note: in JavaScript I'm adding the "underlined-animated"-class after a timeout.
I've tried fiddling around with some keyframes.
em::after {
content: "";
height: 1px;
width: 0;
display: inline-block;
position: absolute;
left: 0;
background: green;
transition: all;
}
.underlined-animated::after {
animation: underline-animated 5s forwards;
}
@keyframes underline-animated {
0% {width: 0;}
50% {width: 100%; left: initial; right:0;}
100% {width: 0;}
}
I'm expecting the line to grow from left to the right – to 100% width of it's container – and then expecting it to shrink from right to left – to 0% width of it's container – all in one animation.
The result of the above code is just a weirdly growing and shrinking line.