Sub topic 13
Inspecting and Debugging Motion in Browser Developer Tools
This chapter assumes you can write a basic transition and a @keyframes animation, and that you know how to open your browser's developer tools (DevTools). The panel names below follow Chrome and Edge. Firefox has a similar Animations panel with slightly different labels.
Why motion is hard to debug
Motion happens fast. A 200 ms transition is over before you can read the computed styles. DevTools lets you slow motion down, replay it, and see which rules are in play.
Most motion bugs come from a few causes:
- The property is not animatable, or the value cannot be interpolated.
- A later rule overrides the
transitionoranimationdeclaration. - The transition is declared only on the hover state, so it does not run on the way back.
- The animation name in
animationdoes not match the@keyframesname.
Inspect the rules that apply
Select the element in the Elements panel and open the Styles pane. Check these things first:
- Find the
transitionoranimationdeclaration. If it is crossed out, a later or more specific rule is winning. - Click the small easing swatch next to a timing function. Chrome opens a curve editor so you can adjust a
cubic-bezier()visually. - Switch to the Computed pane and search for
transitionoranimation. Computed values show what the browser actually applied, includingtransition-property: allwhen you used the shorthand without a property. - Look for
@keyframesrules in the Styles pane. A missing block usually means a spelling mismatch.
Use the Animations panel
Open the command menu with Ctrl+Shift+P (Cmd+Shift+P on macOS), type "Animations", and choose Show Animations. The panel records every transition and animation that starts while it is open.
Each recorded item appears as a group on a timeline. You can:
- Click a group to replay it.
- Change the playback speed to 25% or 10% to watch each step.
- Drag the playhead to scrub to an exact moment.
- Drag the start, end, or keyframe handles to try new timing. The panel shows the change but does not edit your source file, so copy the values back yourself.
.button {
background-color: #2563eb;
transition: background-color 200ms ease-out, transform 200ms ease-out;
}
.button:hover {
background-color: #1d4ed8;
transform: translateY(-2px);
}Open the panel, then hover the button. You should see two bars, one for background-color and one for transform. If only one bar appears, the other property is not changing or is not listed in transition.
Force a state
You cannot hold the mouse on an element while you edit its styles. Use the :hov button in the Styles pane to force :hover, :focus, :active, or :focus-visible on the selected element. The :hover rules then stay applied, and you can edit values and see the result.
Check what costs time
Open the Performance panel, record while the motion runs, and look at the frames. Long purple (layout) or green (paint) blocks on every frame suggest you are animating a property such as width or top. Switching to transform or opacity usually removes them. The Rendering tab can also show Paint flashing, which highlights areas that repaint.
Test reduced motion
Open the Rendering tab and set Emulate CSS media feature prefers-reduced-motion to reduce. Replay the motion. If it still runs, your @media (prefers-reduced-motion: reduce) rule is missing, too narrow, or overridden by a more specific selector.
Exercise
You hover a button and nothing animates. The Animations panel records no group, and the transition declaration in Styles is not crossed out. Name two things to check next.
Show answer
Check that the hover rule actually changes a property value (a transition needs a change to run), and that the changed property is animatable and covered by transition-property. You can also check that the duration is not 0s.