offset
CSS
shorthand property
sets all the properties required for animating an element along a defined path.
注意
: Early versions of the spec called this property
motion
.
此特性是下列 CSS 特性的简写:
/* Offset position */
offset: auto;
offset: 10px 30px;
offset: none;
/* Offset path */
offset: ray(45deg closest-side);
offset: path('M 100 100 L 300 100 L 200 300 z');
offset: url(arc.svg);
/* Offset path with distance and/or rotation */
offset: url(circle.svg) 100px;
offset: url(circle.svg) 40%;
offset: url(circle.svg) 30deg;
offset: url(circle.svg) 50px 20deg;
/* Including offset anchor */
offset: ray(45deg closest-side) / 40px 20px;
offset: url(arc.svg) 2cm / 0.5cm 3cm;
offset: url(arc.svg) 30deg / 50px 100px;
| 初始值 |
as each of the properties of the shorthand:
|
|---|---|
| 适用于 | transformable elements |
| 继承 | no |
| 百分比 |
as each of the properties of the shorthand:
|
| 计算值 |
as each of the properties of the shorthand:
|
| 动画类型 |
as each of the properties of the shorthand:
|
| Creates stacking context | yes |
[ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> || <'offset-rotate'> ]? ]? ]! [ / <'offset-anchor'> ]?
<div id="offsetElement"></div>
@keyframes move {
from {
offset-distance: 0%;
}
to {
offset-distance: 100%;
}
}
#offsetElement {
width: 50px;
height: 50px;
background-color: blue;
offset: path("M 100 100 L 300 100 L 200 300 z") auto;
animation: move 3s linear infinite;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Motion Path Module Level 1
The definition of 'offset' in that specification. |
工作草案 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
offset
|
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
|
完整支持
不支持
用户必须明确启用此特征。
使用非标名称。