Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

offset-distance — distance along a path

offset-distance sets a position along offset-path. Percentages refer to the path length, not the element’s size.

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

Syntax

offset-distance: <length-percentage>;

offset-distance accepts <length-percentage>, such as 40px or 50%. Its initial value is 0; it is not inherited. Without offset-path, it has no effect.

On an open path(), distance is clamped to its endpoints; on a closed path, it wraps. offset-anchor selects the element point placed on the path, while offset-rotate controls rotation.

Animating the value moves the element along the path without changing neighboring layout. The example shows the static midpoint of a 200px segment.

Examples

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

Result

A blue 20px square centered at (120px, 40px) relative to the stage; its top-left corner is (110px, 30px).

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