position-area
The position-area
property places an element in relation to
its anchor, using 1 or 2 keywords to define the position on each axis.
In browsers that support position-area
, this creates a new
containing block for the positioned element based on the position of the
anchor. The polyfill achieves this by wrapping the positioned element in
a <POLYFILL-POSITION-AREA>
element. Be aware that
this may impact selectors that target the positioned element using
direct child or sibling selectors.
This approach also causes some differences with content that is shifted to stay within its containing block in supporting browsers.
Note: We strive to keep the polyfill up-to-date with ongoing changes to the spec, and we welcome code contributions and financial support to make that happen.
bottom center β
span-left top β
center left β
inline-start block-end β
start end β
end β
no space around anchor, end start β
no block space around anchor, span-all top β
inline styles β
One declaration, different containing blocks β
Anchor inset values need to be different for each element matching a declaration, as their values depend on their containing blocks. Should be `right bottom`.
cascade should be respected β
Should be right top
. Also has
right bottom
applied, with less specificity. When the
cascaded value changes, the positioned element will only update to
reflect the changes the next time the polyfill recalculates the
positions, for instance, on scroll.
self
no block space around anchor, span-all left β
If the target overflows the containing block, and the target is shifted
to the start of the containing block in browsers that support CSS anchor
positioning, you can approximate the same behavior by adding an inline
style to add safe
overflow alignment for the impacted axis.
There is not a similar solution for content that supporting browsers
shift to the end of the containing block.
style="align-self: var(--position-area-align-self) safe"
Shifting content to stay inside containing block β
Targets should get shifted to stay within the containing block.
span-all positioned correctly on non-centered anchors β
Should be positioned on anchor-center, not center.
At OddBird, we love contributing to the languages & tools developers rely on. Weβre currently working on polyfills for new Popover & Anchor Positioning functionality, as well as CSS specifications for functions, mixins, and responsive typography. Help us keep this work sustainable and centered on your needs as a developer! We display sponsor logos and avatars on our website.
Sponsor OddBirdβs OSS Work