offset

CSS offset Property

The offset property animates an element along the specified path.

It is a shorthand property for the following properties:

  • offset-position

  • offset-path

  • offset-anchor

  • offset-rotate

  • offset-distance

The offset property was called “motion” in the earlier specification.

This property is an experimental technology.

类目类目
Initial Valueauto none 0 auto auto
Applies toTransformable elements.
InheritedNo.
AnimatableYes.
VersionMotion Path Module Level 1
DOM SyntaxObject.style.offset = “auto”;

Syntax

Syntax

offset: offset-position / offset-path / offset-distance / offset-anchor / offset-rotate | initial | inherit;

Example of the offset property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      @keyframes move {
        from {
          offset-distance: 0%;
        }
        to {
          offset-distance: 100%;
        }
      }
      div {
        width: 60px;
        height: 60px;
        background-color: #8ebf42;
        offset: path("M 100 100 L 300 100 L 200 300 z") auto;
        animation: move 4s linear infinite;
      }
    </style>
  </head>
  <body>
    <h2>Offset property example</h2>
    <div></div>
  </body>
</html>

Values

Values

ValueDescription
offset-positionSpecifies the initial position of the offset path.
offset-pathSpecify a movement path for an element to follow.
offset-distanceSpecifies the position along the offset-path.
offset-anchorDefines an anchor point of the box along the offset path.
offset-rotateSpecifies the orientation of an element.
initialMakes the property use its default value.
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部