People provide a CSS example but omit that the parent needs to be position relative, only works with absolute positioning (which it isn't set to in the example), only certain element types, or that the tree needs a higher z-index than the sibling or it won't work.
At least on Stackoverflow someone often remarks in a reply about the gotcha/limitation.
To be fair, centering with flex doesn't require the parent to have any particular positioning set. The only reason you need to set the width/height is because the centering happens inside 0 size box, which wouldn't happen if your problem is centering something inside existing box.
People provide a CSS example but omit that the parent needs to be position relative, only works with absolute positioning (which it isn't set to in the example), only certain element types, or that the tree needs a higher z-index than the sibling or it won't work.
At least on Stackoverflow someone often remarks in a reply about the gotcha/limitation.