offset-distance
CSS property specifies a position along an
offset-path
for an element to be placed.
/* Default value */ offset-distance: 0; /* the middle of the offset-path */ offset-distance: 50%; /* a fixed length positioned along the path */ offset-distance: 40px;
<length-percentage>
offset-path
).
offset-path
is defined as a basic shape or
path()
).
| 初始值 |
0
|
|---|---|
| 适用于 | transformable elements |
| 继承 | no |
| 百分比 | refer to the total path length |
| 计算值 |
for
<length>
the absolute value, otherwise a percentage
|
| 动画类型 | a length , percentage or calc(); |
<length-percentage>where
<length-percentage> = <length> | <percentage>
The motion aspect in CSS Motion Path typically comes from animating the
offset-distance
property. If you want to animate an element along its full path, you would define its
offset-path
and then set up an animation that takes the
offset-distance
from
0%
to
100%
.
<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
The definition of 'offset-distance' in that specification. |
工作草案 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
offset-distance
|
Chrome
完整支持
55
|
Edge
完整支持
79
|
Firefox
完整支持
72
|
IE 不支持 No |
Opera
完整支持
42
|
Safari 不支持 No |
WebView Android
完整支持
55
|
Chrome Android
完整支持
55
|
Firefox Android 不支持 No |
Opera Android
完整支持
42
|
Safari iOS 不支持 No |
Samsung Internet Android
完整支持
6.0
|
完整支持
不支持
用户必须明确启用此特征。
使用非标名称。
offset
offset-anchor
offset-distance
offset-path
offset-position
offset-rotate