offset
Quick Summary for offset
The offset CSS shorthand property sets all the properties required for animating an element along a defined path.
Code Usage for offset
/* Offset position */ offset: auto; offset: 10px 30px; offset: none;  /* Offset path */ offset: ray(45deg closest-side); offset: path('M 100 100 L 300 100 L 200 300 z'); offset: url(arc.svg);  /* Offset path with distance and/or rotation */ offset: url(circle.svg) 100px; offset: url(circle.svg) 40%; offset: url(circle.svg) 30deg; offset: url(circle.svg) 50px 20deg;  /* Including offset anchor */ offset: ray(45deg closest-side) / 40px 20px; offset: url(arc.svg) 2cm / 0.5cm 3cm; offset: url(arc.svg) 30deg / 50px 100px;  /* Global values */ offset: inherit; offset: initial; offset: revert; offset: unset; 
More Details for offset

offset

The offset CSS shorthand property sets all the properties required for animating an element along a defined path.

Note: Early versions of the spec called this property motion.

Constituent properties

This property is a shorthand for the following CSS properties:

offset-anchor offset-distance offset-path offset-position offset-rotate

Syntax

/* Offset position */ offset: auto; offset: 10px 30px; offset: none;  /* Offset path */ offset: ray(45deg closest-side); offset: path('M 100 100 L 300 100 L 200 300 z'); offset: url(arc.svg);  /* Offset path with distance and/or rotation */ offset: url(circle.svg) 100px; offset: url(circle.svg) 40%; offset: url(circle.svg) 30deg; offset: url(circle.svg) 50px 20deg;  /* Including offset anchor */ offset: ray(45deg closest-side) / 40px 20px; offset: url(arc.svg) 2cm / 0.5cm 3cm; offset: url(arc.svg) 30deg / 50px 100px;  /* Global values */ offset: inherit; offset: initial; offset: revert; offset: unset; 

Formal definition

Initial valueas each of the properties of the shorthand:offset-position: autooffset-path: noneoffset-distance: 0offset-anchor: autooffset-rotate: auto
Applies totransformable elements
Inheritedno
Percentagesas each of the properties of the shorthand:offset-position: referToSizeOfContainingBlockoffset-distance: refer to the total path lengthoffset-anchor: relativeToWidthAndHeight
Computed valueas each of the properties of the shorthand:offset-position: for <length> the absolute value, otherwise a percentageoffset-path: as specifiedoffset-distance: for <length> the absolute value, otherwise a percentageoffset-anchor: for <length> the absolute value, otherwise a percentageoffset-rotate: as specified
Animation typeas each of the properties of the shorthand:offset-position: a positionoffset-path: as <angle>, <basic-shape> or <path()>offset-distance: a length, percentage or calc();offset-anchor: a positionoffset-rotate: as <angle>, <basic-shape> or <path()>
Creates stacking contextyes

Formal syntax

[ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> || <'offset-rotate'> ]? ]? ]! [ / <'offset-anchor'> ]?

Examples

Animating an element along a path

HTML
<div id="offsetElement"></div> 
CSS
@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; } 
Result

Specifications

Specification
Motion Path Module Level 1 # offset-shorthand

See also

offset-anchor offset-distance offset-path offset-position offset-rotate

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)Français日本語Português (do Brasil)中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
If you work on something a little bit every day, you end up with something that is massive.
Kenneth Goldsmith
Random CSS Property

:current

The :current CSS pseudo-class selector is a time-dimensional pseudo-class that represents the element, or an ancestor of the element, that is currently being displayed. For example in a video with captions which are being displayed by WebVTT.
:current css reference