Could you help me with modifying this CSS animation? I want to adjust the animation-iteration-count
to 1
only when a certain property, status
, is added to the element. Currently, the animation is not working as expected.
For example:
setTimeout(() => {
const e = document.querySelector('div')
e.classList.add('status')
}, 5000)
div {
position: relative;
}
div::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
border-bottom: 2px solid #00849b;
animation-name: border-animation;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-fill-mode: forwards;
}
div.status::before {
animation-name: border-animation;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
@keyframes border-animation {
from {
width: 0;
}
to {
width: 100%;
}
}
<div>Hiiiiiiiii!</div>