CSS Reference ยท Transforms, Transitions and Animations
The offset-distance property
Reference for the CSS offset-distance property: place an element at a length or percentage along its offset-path, and animate it to move along a curve.
The offset-distance property says how far along its offset-path an element sits. At 0% it is at the start of the path, at 100% at the end. Animating or transitioning this value is how you make something travel along a motion path.
It has no effect unless offset-path is set to something other than none.
.dot { offset-path: path("M 10 50 L 300 50"); offset-distance: 50%; }
Try it
The path is 320px long, so 50% lands in the middle and 120px lands at the same place as 37.5%.
Syntax
offset-distance: <length-percentage>
- Initial value:
0 - Applies to: transformable elements
- Inherited: no
- Animatable: yes, as a length or percentage
- Percentages: refer to the total length of the path
- Computed value: an absolute length or a percentage
Values
| Value | Description |
|---|---|
<length> |
A distance from the start of the path, for example 120px. |
<percentage> |
A fraction of the total path length. 0% is the start, 100% the end. |
Usage notes
- Closed shapes. Some shapes, such as a circle, loop. Values over
100%then wrap around, while on open paths they are clamped to the end. - Transitions work. Just like other properties,
transition: offset-distance 1sanimates between two states, as the last row of the example shows. - Keyframes. For continuous travel, animate from
0%to100%withlineareasing andinfinite. - Negative delays let several elements start at different points of the same loop:
animation-delay: -1s,-2sand so on. - Without a path, nothing happens. If an element does not move, check that
offset-pathis valid, that the element is positioned or transformable, and that the path coordinates fall inside the containing block. - The anchor decides which point rides.
offset-anchorselects the element's point placed on the path, which defaults to its center. - Motion safety. Long or looping movement should respect
prefers-reduced-motion.
Browser support
Supported in current versions of the major browsers along with motion paths. If you target older browsers, check a compatibility table; they ignore the property and show the element in its normal position.