@@ -94,8 +94,8 @@ The ''anchor()'' function resolves to a <<length>>.
9494
9595<pre class=prod>
9696<anchor()> = anchor( <<anchor-element>> ? <<anchor-side>> , <<length-percentage>> ? )
97- <dfn><<anchor-element>></dfn> = auto | <<dashed-ident>> | implicit | popover
98- <dfn><<anchor-side>></dfn> = top | left | right | bottom
97+ <dfn><<anchor-element>></dfn> = <<dashed-ident>> | implicit | popover
98+ <dfn><<anchor-side>></dfn> = auto | top | left | right | bottom
9999 | start | end | self-start | self-end
100100 | <<percentage>> | center
101101</pre>
@@ -105,15 +105,11 @@ The ''anchor()'' function has three arguments:
105105* the <<anchor-element>> value
106106 specifies how to find the [=anchor element=]
107107 it will be drawing positioning information from.
108- If omitted, it behaves as ''auto'' .
108+ If omitted, it behaves as the element's [=default anchor specifier=] .
109109
110110 Its possible values are:
111111
112112 <dl dfn-type=value dfn-for="anchor()">
113- : <dfn>auto</dfn>
114- :: Uses the [=default anchor specifier=] ,
115- as specified by 'anchor-default' .
116-
117113 : <dfn><<dashed-ident>></dfn>
118114 :: Specifies the [=anchor name=] it will look for.
119115 This name is a [=tree-scoped reference=] .
@@ -135,6 +131,10 @@ The ''anchor()'' function has three arguments:
135131 refers to the position of the corresponding side
136132 of the [=target anchor element=] .
137133
134+ The <dfn value for=anchor()>auto</dfn> keyword
135+ indicates [=automatic anchor positioning=] .
136+ See [[#auto-anchor]] for details.
137+
138138 The physical <<anchor-side>> keywords
139139 (<dfn value for=anchor()>left</dfn> ,
140140 <dfn value for=anchor()>right</dfn> ,
@@ -265,6 +265,79 @@ as if by an additional ''translate()'' transform.
265265 which input is being referred to.
266266</div>
267267
268+ <!-- Big Text: auto -->
269+
270+ <h4 id=anchor-auto>
271+ Automatic Anchor Positioning</h4>
272+
273+ A positioned element can use <dfn>automatic anchor positioning</dfn>
274+ by specifying ''anchor()/auto'' as its <<anchor-side>> value,
275+ causing the element to automatically stick "next to" the [=anchor element=]
276+ in the most obvious way,
277+ and flip to the other side if necessary.
278+
279+ [=Automatic anchor positioning=] is only valid
280+ if the opposite [=inset property=] is ''top/auto'' .
281+ (For example, if an element had ''top: anchor(auto);'' ,
282+ it would have to also have ''bottom: auto;'' .)
283+ If this is not the case,
284+ the ''anchor()'' function represents an [=invalid anchor query=] .
285+
286+ When used in a given [=inset property=] ,
287+ the ''anchor()/auto'' <<anchor-side>>
288+ behaves as the opposite side of the property it's used in.
289+ That is, when used in ''top: anchor(auto);'' ,
290+ it's equivalent to ''top: anchor(bottom);'' ;
291+ when used in ''bottom: anchor(auto);'' ,
292+ it's equivalent to ''bottom: anchor(top);'' ;
293+ etc.
294+
295+ Additionally,
296+ it automatically adds one entry
297+ to the beginning of the element's [=position fallback list=]
298+ (preceding any entries added by 'position-fallback' ),
299+ specifying the [=inset property=] the function is used in
300+ as ''top/auto'' ,
301+ and the opposite property as this property's value.
302+
303+ <div class=example>
304+ For example, the following code using [=automatic anchor positioning=] :
305+
306+ <pre highlight=css>
307+ .foo {
308+ position: absolute;
309+ top: calc(.5em + anchor(--foo auto));
310+ }
311+ </pre>
312+
313+ is equivalent to the following more verbose and explicit code:
314+
315+ <pre highlight=css>
316+ .foo {
317+ position: absolute;
318+ top: calc(.5em + anchor(--foo bottom));
319+ position-fallback: --flip;
320+ }
321+ @position-fallback --flip {
322+ @try {
323+ top: auto;
324+ bottom: calc(.5em + anchor(--foo top));
325+ }
326+ }
327+ </pre>
328+ </div>
329+
330+ If the element uses [=automatic anchor positioning=] in both axises,
331+ it instead adds three entries to the [=position fallback list=] :
332+ one reversing just the block axis,
333+ one reversing just the inline axis,
334+ and finally one reversing both axises at once.
335+
336+ ''anchor(auto)'' functions specified <em> in</em> a [=position fallback list's=] styles
337+ do not cause any entries to be added to the list;
338+ they merely resolve to the appropriate side as normal.
339+
340+
268341<!--
269342 ███ ██████ ████ ████████ ████████ ███ ███
270343 ██ ██ ██ ██ ██ ██ ██ ██ ██
0 commit comments