--- title: offset-distance slug: Web/CSS/offset-distance tags: - CSS - Propriété - Reference - motion-offset - offset-distance translation_of: Web/CSS/offset-distance ---
La propriété offset-distance définit une position le long d'un chemin {{CSSxRef("offset-path")}}.
/* Valeur par défaut */ offset-distance: 0; /* La position à la moitié de offset-path */ offset-distance: 50%; /* Une position absolue le long du chemin */ offset-distance: 40px;
{{cssxref('<length-percentage>')}}offset-path est défini par une forme simple ou grâce à la fonction path()).{{CSSSyntax}}
La notion de mouvement contenue dans CSS Motion Path vient principalement de la propriété offset-distance. Si on souhaite animer un élément le long du chemin, on définira un chemin avec {{cssxref('offset-path')}} et on utilisera une animation qui fera évoluer offset-distance de 0% à 100%.
<div id="motion-demo"></div>
#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%;
}
}
{{EmbedLiveSample('Animation')}}
| Spécification | État | Commentaires |
|---|---|---|
| {{SpecName('Motion Path Level 1', '#offset-distance-property', 'offset-distance')}} | {{Spec2('Motion Path Level 1')}} | Définition initiale. |
{{CSSInfo}}
Note : Dans les versions antérieures de la spécification, cette propriété était intitulée motion-offset.
{{Compat("css.properties.offset-distance")}}