Why does my CSS transition not run when I change a property?
Quick answer
A CSS transition needs a before-and-after value change, a transition declaration that applies to the changed property, and a duration greater than zero. Check the element’s computed styles in both states, confirm the property is listed in transition-property or the shorthand, and look for rules that override the declaration. A zero duration makes the change instantaneous. [S1] [S2]
The question, the details, the next step.
A practical checklist
Confirm the property’s value changes between the two states.
Make sure the applicable transition names that property.
Set a duration greater than zero; the default is
0s. [S2]Check shorthand order: property, duration, timing function, delay. [S1]
Inspect matching selectors and rules that may override the transition. [S1]
Test a minimal example, then restore other rules one at a time.
A few more useful answers
Does `transition: all` solve a transition that is not running?
Can a delay make it look like nothing is happening?
Yes, a delay can postpone when a transition begins. The shorthand places the delay after the property, duration, and timing function. [S1]
Sources
References used for this guide.
- [S1] Using CSS transitions — MDN developer.mozilla.org · Checked
- [S2] transition-duration CSS property — MDN developer.mozilla.org · Checked
