My personal solution was this:
.example {
padding: 20px;
background-color: #efefef;
transition: background-color 0.3s ease-in 0s;
}
.example.active {
background-color: green;
transition-delay: 1s;
}
An !important
declaration is unnecessary because the cascade will automatically prioritize the later rule when a property is overwritten.
You don't have to rewrite the entire transition rule if you specifically want to keep the same transition with a different delay, rather than a completely different transition.
The reason for having the default delay as 0s
is that when you remove the .active
class, both its color and transition delay are no longer applied, so the delay specified in the .example
class takes effect.