Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `position-try-fallbacks`

`position-try-fallbacks` supplies a comma-separated list of additional position options that an absolute box can try after its base styles to avoid overflow.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

none | [ [ <dashed-ident> || <try-tactic> ] | <position-area> ]#

position-try-fallbacks supplies a comma-separated list of additional position options that an absolute box can try after its base styles to avoid overflow.

In the example the base placement below the anchor does not fit, so the flip-block tactic mirrors it above the anchor; the control value none leaves the list without extra options.

Grammar: none | [ [ <dashed-ident> || <try-tactic> ] | <position-area> ]#.

Each list item can be a named @position-try rule, a tactic, their combination, or a position area. An unknown name adds nothing, logical tactics depend on writing mode, and multiple tactics in one item compose into one option; the resulting options are tried in sequence.

Examples

<!doctype html><meta charset="utf-8"><style>html,body{margin:0}.stage{position:relative;width:200px;height:200px}.anchor{position:absolute;left:80px;top:170px;width:40px;height:20px;anchor-name:--a}.tip{position:absolute;position-anchor:--a;position-area:block-end;width:80px;height:40px;position-try-fallbacks:flip-block}.none{position:absolute;left:5px;top:5px;position-try-fallbacks:none}</style><div class="stage"><i class="anchor"></i><b id="tip" class="tip"></b><b id="none" class="none"></b></div><pre id="result"></pre><script>const a=tip.getBoundingClientRect(),p=[Math.round(a.left),Math.round(a.top)],x=getComputedStyle(tip).positionTryFallbacks,y=getComputedStyle(none).positionTryFallbacks;if(p.join(',')!=='60,130'||x!=='flip-block'||y!=='none')throw new Error('fallback mismatch '+[p,x,y]);result.textContent='flipped='+p.join(',')+'; computed='+x+'/'+y;</script>

Result

flipped=60,130; computed=flip-block/none

In the example the base placement below the anchor does not fit, so the `flip-block` tactic mirrors it above the anchor; the control value `none` leaves the list without extra options.

Sources