I am currently working on an input box that has a CSS animation applied to it. This animation creates a smooth fade-in effect when the page is loaded.
Here is the CSS code:
#search-box {
/* ... */
animation: 2s fade-in
}
@keyframes fade-in {
from { opacity: 0 }
to { opacity: 1 }
}
However, there are times when I want the animation to stop and immediately set the opacity to 1
when a specific URL parameter is present during page load.
I have attempted to use animation-play-state
and tried using !important
to override the opacity property, but so far, I have not been successful.
My Javascript approach:
let endAnimation = // ... boolean
if (endAnimation) {
let elem = document.getElementById('search-box');
// Need to figure out how to end the animation and set opacity to 1.
}
In the HTML section:
<input id="search-box">