Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

offset-position — path starting position

For a path function that uses the offset starting position, such as `ray()`, `offset-position` can supply that position when the optional position argument is omitted. `inset()` has no such argument and derives its path perimeter from the reference box.

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

Syntax

offset-position: normal | auto | <position>;

offset-position applies to transformable elements and is not inherited. Its initial value is normal: no supplied starting position; ray() then defaults to the center.

auto selects the top-left corner of the element’s own box. In contrast, <position>, such as left top or 25% 50%, selects a point relative to the containing block. Percentages use its dimensions, without subtracting the element’s size.

An explicit at <position> in ray() takes precedence. offset-distance selects distance along the path; offset-anchor selects the element’s point placed there. With offset-path: none, there is no offset transform.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Setting a motion path starting position</title>
  <style>
    .stage { position: relative; width: 200px; height: 120px; background: #eee; }
    #dot {
      position: absolute;
      top: 0;
      left: 0;
      width: 10px;
      height: 10px;
      background: #064;
      offset-path: ray(90deg);
      offset-position: 25% 50%;
      offset-distance: 20px;
      offset-anchor: left top;
      offset-rotate: 0deg;
    }
  </style>
</head>
<body>
  <p>The ray omits an explicit starting position so that <code>offset-position</code> can supply one. This example checks syntax and computed style, not the ray's rendered origin.</p>
  <div class="stage" aria-hidden="true"><div id="dot"></div></div>
  <script>
    if (CSS.supports('offset-position', '25% 50%')) {
      const value = getComputedStyle(document.getElementById('dot')).getPropertyValue('offset-position');
      console.log(`offset-position syntax: supported; computed value: ${value}`);
    } else {
      console.log('offset-position syntax: unsupported');
    }
  </script>
</body>
</html>

Result

offset-position syntax: supported; computed value: 25% 50%

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