if your div has a dynamic/undefined width and/or height, then instead of the margin, set the transform to the negative half of the div's relative width and height.
margin
transform
<div class="fixed left-[50%] -translate-x-1/2 m-auto z-20"></div>
Last updated 1 year ago