CSS motion path

Das CSS motion path-Modul erlaubt es Autoren, jedes grafische Objekt entlang eines benutzerdefinierten Pfades zu animieren.

Die Idee dahinter ist, dass Sie, wenn Sie ein Element entlang eines Pfades animieren möchten, zuvor nur die Animation von Translation, Position usw. zur Verfügung hatten, was nicht ideal war und nur einfache Bewegungen erlaubte. Mit offset-path können Sie einen bestimmten Pfad in beliebiger Form definieren. Sie animieren es dann entlang dieses Pfades, indem Sie offset-distance animieren, und können es an jedem Punkt mit offset-rotate rotieren lassen.

Einfaches Beispiel

html
<div id="motion-demo"></div>
css
#motion-demo {
  offset-path: path("M20,20 C20,100 200,0 200,100");
  animation: move 3000ms infinite alternate ease-in-out;
  width: 40px;
  height: 40px;
  background: cyan;
}

@keyframes move {
  0% {
    offset-distance: 0%;
  }
  100% {
    offset-distance: 100%;
  }
}

Referenz

Eigenschaften

Funktionen

Spezifikationen

Specification
Motion Path Module Level 1
# offset-path-property

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
offset-path
<basic-shape>
border-box
content-box
fill-box
margin-box
Experimental
none
padding-box
Support for path() function as a value
Support for ray() function as a value
stroke-box
<url>
view-box

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
Uses a non-standard name.
Has more compatibility info.