这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
Motion Path is a CSS module that allows authors to animate any graphical object along a custom path.
The idea is that when you want to animate an element moving along a path, you previously only had animating translation, position, etc. at your disposal, which wasn't ideal and only allowed for simple movements. With
offset-path
you can define a specific path of any shape you want. You then animate it along that path by animating
offset-distance
, and can choose to rotate it at any point using
offset-rotate
.
<div id="motion-demo"></div>
#motion-demo {
offset-path: path('M20,20 C20,100 200,0 200,100');
animation: move 3000ms infinite alternate ease-in-out;
width: 40px;
height: 40px;
background: cyan;
}
@keyframes move {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
| Motion Path Module Level 1 | 工作草案 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
offset-path
|
Chrome
完整支持
55
|
Edge
完整支持
79
|
Firefox
完整支持
72
|
IE 不支持 No |
Opera
完整支持
45
|
Safari 不支持 No |
WebView Android
完整支持
55
|
Chrome Android
完整支持
55
|
Firefox Android
完整支持
63
Disabled
|
Opera Android
完整支持
43
|
Safari iOS 不支持 No |
Samsung Internet Android
完整支持
6.0
注意事项
|
Supports the
path()
function as a value
|
Chrome 完整支持 64 | Edge 完整支持 79 | Firefox 完整支持 63 | IE 不支持 No | Opera 完整支持 51 | Safari 不支持 No | WebView Android 完整支持 64 | Chrome Android 完整支持 64 | Firefox Android 完整支持 63 | Opera Android 完整支持 47 | Safari iOS 不支持 No | Samsung Internet Android 完整支持 9.0 |
Supports the
ray()
function as a value
|
Chrome 完整支持 64 | Edge 完整支持 79 |
Firefox
完整支持
71
Disabled
|
IE 不支持 No | Opera 完整支持 51 | Safari 不支持 No | WebView Android 完整支持 64 | Chrome Android 完整支持 64 | Firefox Android 不支持 No | Opera Android 完整支持 47 | Safari iOS 不支持 No | Samsung Internet Android 完整支持 9.0 |
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
使用非标名称。