offset-anchor
Quick Summary for offset-anchor
The offset-anchor CSS property specifies the point inside the box of an element travelling along an offset-path that is actually moving along the path.
Code Usage for offset-anchor

<pre class="brush: css notranslate"><code><span class="token comment">/ Keyword values /</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> top<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> bottom<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> right<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span> <span class="token comment">/ &lt;percentage&gt; values /</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> 25% 75%<span class="token punctuation">;</span> <span class="token comment">/ &lt;length&gt; values /</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> 0 0<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> 1cm 2cm<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> 10ch 8em<span class="token punctuation">;</span> <span class="token comment">/ Edge offsets values /</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> bottom 10px right 20px<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> right 3em bottom 10px<span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> revert<span class="token punctuation">;</span> <span class="token property">offset-anchor</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for offset-anchor

offset-anchor

The offset-anchor CSS property specifies the point inside the box of an element travelling along an offset-path that is actually moving along the path.

Syntax

/* Keyword values */ offset-anchor: top; offset-anchor: bottom; offset-anchor: left; offset-anchor: right; offset-anchor: center; offset-anchor: auto;  /* <percentage> values */ offset-anchor: 25% 75%;  /* <length> values */ offset-anchor: 0 0; offset-anchor: 1cm 2cm; offset-anchor: 10ch 8em;  /* Edge offsets values */ offset-anchor: bottom 10px right 20px; offset-anchor: right 3em bottom 10px;  /* Global values */ offset-anchor: inherit; offset-anchor: initial; offset-anchor: revert; offset-anchor: unset; 

Values

auto

offset-anchor is given the same value as the element's transform-origin, unless offset-path is none, in which case it takes its value from offset-position.

<position>

A <position> defines an x/y coordinate, to place an item relative to the edges of an element's box. It can be defined using one to four values. For more specifics, see the <position> and background-position reference pages. Note that the 3-value position syntax does not work for any usage of <position>, except for in background(-position).

Formal definition

Initial valueauto
Applies totransformable elements
Inheritedno
PercentagesrelativeToWidthAndHeight
Computed valuefor <length> the absolute value, otherwise a percentage
Animation typea position

Formal syntax

auto | <position>

where <position> = [ [ left | center | right ] || [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]

where <length-percentage> = <length> | <percentage>

Examples

Setting various offset-anchor values

In the following example, we have three <div> elements nested in <section> elements. Each <div> is given the same offset-path (a horizontal line 200 pixels long) and animated to move along it. The three are then given different background-color and offset-anchor values.

Each <section> has been styled with a linear gradient to give it a horizontal line running through its center, to give you a visual display of where the <div>'s offset paths are running.

This allows you to see what effect the different offset-anchor values have — the first one, auto, causes the <div>'s center point to move along the path. The other two cause the <div>'s top-right and bottom-left points to move along the path, respectively.

HTML
<section>   <div class="offset-anchor1"></div> </section> <section>   <div class="offset-anchor2"></div> </section> <section>   <div class="offset-anchor3"></div> </section> 
CSS
div {   offset-path: path('M 0,20 L 200,20');   animation: move 3000ms infinite alternate ease-in-out;   width: 40px;   height: 40px; }  section {   background-image: linear-gradient(to bottom, transparent, transparent 49%, #000 50%, #000 51%, transparent 52%);   border: 1px solid #ccc;   margin-bottom: 10px; }  .offset-anchor1 {   offset-anchor: auto;   background: cyan; }  .offset-anchor2 {   offset-anchor: right top;   background: purple; }  .offset-anchor3 {   offset-anchor: left bottom;   background: magenta; }  @keyframes move {   0% {     offset-distance: 0%;   }   100% {     offset-distance: 100%;   } } 
Result

Specifications

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

See also

offset offset-distance offset-rotate SVG <path>

Last modified: Feb 8, 2022, by MDN contributors

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...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

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


Me
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.