--- title: offset-distance slug: Web/CSS/offset-distance tags: - CSS - CSS Motion Path - CSS Property - CSS プロパティ - CSS モーションパス - Experimental - Motion Path - Reference - motion-offset - offset-distance - 'recipe:css-property' - モーションパス translation_of: Web/CSS/offset-distance ---
offset-distance は CSS プロパティで、 {{CSSxRef("offset-path")}} 上の要素を配置する位置を指定します。
/* 既定値 */ offset-distance: 0; /* offset-path の途中 */ offset-distance: 50%; /* パス上の固定距離の位置 */ offset-distance: 40px;
{{cssxref('<length-percentage>')}}offset-path が基本シェイプまたは path() として定義されている場合)。CSS モーションパスのモーションアスペクトは、一般に offset-distance プロパティのアニメーションから来ています。要素をパス全体の上でアニメーションさせたい場合は、その {{cssxref('offset-path')}} を定義し、 offset-distance に 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('Examples', '100%', 150)}}
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName('Motion Path Level 1', '#offset-distance-property', 'offset-distance')}} | {{Spec2('Motion Path Level 1')}} | 初回定義 |
{{CSSInfo}}
{{Compat("css.properties.offset-distance")}}