Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

offset-anchor — the element point aligned to a path

offset-anchor selects the point on an element aligned to a position on its motion path. It changes how the element sits on the path, not the path itself.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

offset-anchor: auto | <position>;

offset-anchor identifies the element point aligned to the position determined by offset-path and offset-distance. It applies to transformable elements and is not inherited.

The initial value auto uses offset-position when offset-path is none. Otherwise, it uses the point specified by transform-origin. It does not necessarily mean the center. An explicit <position>, such as left top, center, or 25% 75%, selects the point independently. Percentages refer to the width and height of the element’s reference box, not the path length.

In the example, offset-rotate: 0deg disables rotation along the path direction. Changing left top to center shifts the rectangle without changing the path or the selected position on it. Setting offset-anchor alone creates neither a path nor an animation.

Examples

<!doctype html>
<meta charset="utf-8">
<title>offset-anchor</title>
<style>
  .stage {
    position: relative;
    width: 240px;
    height: 120px;
    background: #eee;
  }
  .box {
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 20px;
    background: #075;
    offset-path: path("M 20 60 L 220 60");
    offset-distance: 50%;
    offset-rotate: 0deg;
    offset-anchor: left top;
  }
</style>
<div class="stage"><div class="box"></div></div>

Result

left top: (120px, 60px); center: (100px, 50px)

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources