I have an animation like below:
@keyframes pulseColorGreen {
0% {
background-color: green;
}
97%{
background-color: green;
}
100% {
background-color: white;
}
}
My website also has a dark mode where the background goes black. Now in the animation, I want to display a darker green just like below:
@keyframes pulseColorGreen {
0% {
background-color: darkgreen;
}
97%{
background-color: darkgreen;
}
100% {
background-color: black;
}
}
For the dark mode, I add a class "lightsOff" in the body tag. I am managing all other color changes using the combination of the target element class and "lightsOff" class just like:
.lightsOff .someclass{
color: white
}
But when defining an element in css file as:
@keyframes .lightsOff pulseColorGreen {
0% {
background-color: darkgreen;
}
97%{
background-color: darkgreen;
}
100% {
background-color: black;
}
}
It gives me error saying "identifier expected". I am adding the animation-name property to elements dynamically from javascript. Hence, I won't prefer changing the JS code to identify which theme is set currently and set a keyframe accordingly. How can I achieve this?