Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

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]

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I change a CSS property on hover, but it jumps to the new value instead of easing. What should I check first?

Geez

Start with three checks: does the property’s value actually change, does an applicable transition include that property, and is its duration greater than zero? transition-property identifies which properties to transition; a change to a property outside that list happens immediately. The initial duration is 0s, so set a positive duration for a visible transition. [S1] [S2]

Try this small example:

.card {
  opacity: 0.6;
  transition: opacity 300ms ease;
}

.card:hover {
  opacity: 1;
}

The value changes from 0.6 to 1, and the shorthand names the property and sets a nonzero duration. Replace the selector and property with the ones you are troubleshooting.

Follow-up question

How can I tell whether I have the transition shorthand in the wrong order?

Geez

Read the shorthand in this order: property, duration, timing function, then delay. For example, transition: opacity 300ms ease 100ms; specifies those four parts in that sequence. [S1] If you are unsure, temporarily split it into longhand declarations so each setting is easy to inspect:

.card {
  transition-property: opacity;
  transition-duration: 300ms;
  transition-timing-function: ease;
  transition-delay: 0ms;
}

The duration corresponds to the property in the transition-property list. [S2] Check that the property you changed is included and that its applicable duration is positive.

Follow-up question

The declaration looks right, but it still jumps. Could the hover rule or another selector be the problem?

Geez

Yes. Check the element’s styles in both its normal and hover states, and look for a rule that replaces the transition declaration or changes the property you expected to animate. The transition must remain applicable in the cascade when the state change happens. [S1]

A practical debugging pass:

  1. Confirm the selector matches the element in both states.
  2. Compare the property’s before-and-after values; if they are the same, there is no value change to transition.
  3. Inspect the computed transition settings, including the property and duration.
  4. Temporarily remove competing transition declarations, then restore them one at a time.

For example, if a base rule sets transition: opacity 300ms ease but a hover rule replaces it with transition: none, the intended transition may no longer apply. That is an illustrative possibility, not a diagnosis of your stylesheet; the actual cascade depends on your rules.

Follow-up question

Can you give me a reusable checklist and a quick way to isolate the issue without rewriting the whole stylesheet?

Geez

Make a tiny test using the same element and selector, then add back your original rules until the behavior changes. Keep the transition declaration simple at first, such as transition: opacity 300ms ease;, and use a clearly different before-and-after value. If that works in isolation but not on your page, focus on selector matching and competing declarations. If it does not, verify that the property is included and the duration is positive. The cited guidance covers the property list, shorthand order, cascade applicability, and zero-duration behavior; it does not establish what is wrong in a particular stylesheet. [S1] [S2]

Reusable template:

.target {
  /* starting value */
  opacity: 0.6;
  transition: opacity 300ms ease;
}

.target.is-active {
  /* changed value */
  opacity: 1;
}

Replace .target, .is-active, and the example values with your own. Test the simplest version first; then restore other transition settings and state rules one at a time.

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?

Not necessarily. The value still needs to change, an applicable duration must be greater than zero, and the declaration must remain in effect. [S1] [S2]

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]

What if the property changes immediately even though I set a duration?

Check whether the changed property is included in the transition and whether another applicable rule overrides the declaration. Also verify that the duration is not zero. [S1] [S2]

Sources

References used for this guide.

  1. [S1] Using CSS transitions — MDN
    developer.mozilla.org · Checked
  2. [S2] transition-duration CSS property — MDN
    developer.mozilla.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work