CSS Anchor Positioning provides a better way to position an element in relation to another, reducing the need for heavy JavaScript calculations.
The CSS Anchor Positioning API is still relatively new and currently only supported by Chrome Canary behind an 'Experimental Web Platform Features' flag.