--- title: offset slug: Web/CSS/offset tags: - CSS - CSS Motion Path - CSS Property - Experimental - Reference - 'recipe:css-shorthand-property' translation_of: Web/CSS/offset ---
{{CSSRef}}
offset は CSS の一括指定プロパティで、要素を定義された経路に沿って動かすのに必要なすべてのプロパティを設定します。
注: 仕様書の早期の版では、このプロパティを motion と呼んでいました。
このプロパティは以下の CSS プロパティの一括指定です。
/* オフセット位置 */
offset: auto;
offset: 10px 30px;
offset: none;
/* オフセット経路 */
offset: ray(45deg closest-side);
offset: path('M 100 100 L 300 100 L 200 300 z');
offset: url(arc.svg);
/* オフセット経路に距離と回転が加わったもの */
offset: url(circle.svg) 100px;
offset: url(circle.svg) 40%;
offset: url(circle.svg) 30deg;
offset: url(circle.svg) 50px 20deg;
/* オフセットアンカーを含む */
offset: ray(45deg closest-side) / 40px 20px;
offset: url(arc.svg) 2cm / 0.5cm 3cm;
offset: url(arc.svg) 30deg / 50px 100px;
{{cssinfo}}
<div id="offsetElement"></div>
@keyframes move {
from {
offset-distance: 0%;
}
to {
offset-distance: 100%;
}
}
#offsetElement {
width: 50px;
height: 50px;
background-color: blue;
offset: path("M 100 100 L 300 100 L 200 300 z") auto;
animation: move 3s linear infinite;
}
{{EmbedLiveSample("Animating_an_element_along_a_path", 350, 350)}}
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName('Motion Path Level 1', '#offset-shorthand', 'offset')}} | {{Spec2('Motion Path Level 1')}} | 初回定義 |
{{Compat("css.properties.offset")}}