The CSS offset-rotate property controls the rotation of an element as it moves along anoffset-path. It determines whether the element should rotate to face the direction of the path or stay in a fixed orientation.
Note
โ Can automatically rotate along the path
โ Supports angles (deg, rad, turn)
โ Works in all modern browsers
๐ฆ Syntax
offset-rotate syntax
offset-rotate: auto | reverse | <angle>;
/* Examples */
offset-rotate: auto; /* align to path direction */
offset-rotate: reverse; /* align but flipped 180deg */
offset-rotate: 45deg; /* fixed angle */
offset-rotate: auto 30deg; /* auto + angle offset */| Value | Meaning |
|---|---|
| auto | Rotates element to match path direction |
| reverse | Matches direction but flipped 180ยฐ |
| <angle> | Fixed rotation |
| auto <angle> | Auto rotation + angle offset |
๐จ 1. Basic Example (Auto Rotation)
auto rotation
.car {
offset-path: path("M0,0 L200,60 L250,150");
offset-rotate: auto;
animation: drive 4s linear infinite;
}
@keyframes drive {
to { offset-distance: 100%; }
}The car automatically points in the direction of the path.
๐จ 2. Reverse Orientation
reverse
.arrow {
offset-path: path("M0,0 L200,100");
offset-rotate: reverse;
animation: move 2s linear infinite;
}The element follows the path but faces backward.
๐จ 3. Fixed Rotation Angle (No Auto Rotation)
fixed angle
.rocket {
offset-path: path("M0,0 C80,0 160,100 240,80");
offset-rotate: 45deg;
animation: fly 3s ease-in-out infinite;
}The rocket moves along the path but always stays rotated at 45ยฐ.
๐จ 4. Auto Rotation + Angle Offset
auto angle offset
.plane {
offset-path: path("M0,0 C150,0 200,100 300,60");
offset-rotate: auto 20deg;
animation: fly 4s linear infinite;
}The plane rotates with the path but is tilted by an extra 20ยฐ.
๐จ 5. Combine offset-rotate + offset-distance
combine
.ball {
offset-path: path("M0,50 C100,0 180,100 250,50");
offset-rotate: auto;
animation: move 3s ease-in-out infinite;
}
@keyframes move {
to { offset-distance: 100%; }
}Both position and rotation follow the path naturally.
๐จ 6. Circular Motion with Rotation
circular path
.planet {
offset-path: path("M100,50 A50,50 0 1 1 99,50");
offset-rotate: auto;
animation: orbit 5s linear infinite;
}
@keyframes orbit {
to { offset-distance: 100%; }
}Perfect for orbit animations or spinning loaders.
๐ Auto vs Reverse vs Fixed Angle
| Mode | Rotation Behavior |
|---|---|
| auto | Faces direction of the path |
| reverse | Faces opposite direction |
| angle | Always rotated by a fixed degree |
| auto angle | Auto rotation with additional offset |
๐งช Real-World Use Cases
1๏ธโฃ Car Driving Along a Road
car animation
.car {
offset-path: path("M0,100 C100,50 200,150 300,80");
offset-rotate: auto;
animation: drive 3s linear infinite;
}2๏ธโฃ Airplane Banking While Turning
airplane
.plane {
offset-path: path("M0,0 C150,-40 200,100 300,60");
offset-rotate: auto 15deg;
}3๏ธโฃ Falling Leaves Animation
leaf
.leaf {
offset-path: path("M0,0 C50,100 100,-50 150,100");
offset-rotate: auto;
animation: fall 5s ease-in-out infinite;
}โ ๏ธ Common Mistakes
- โ Using offset-rotate without offset-path
- โ Expecting automatic rotation with a fixed angle
- โ Using invalid SVG path syntax inside path()
- โ Forgetting to animate offset-distance for movement
Note
๐ฅ Summary
offset-rotate brings life to motion-path animations by allowing elements to dynamically rotate along the direction of a path. Combined with offset-path and offset-distance, it unlocks smooth and realistic movement.
- auto โ follow path direction
- reverse โ follow backwards
- angle โ fixed rotation
- auto angle โ auto + offset rotation