I was going to say the exact same thing, but you beat me too it!
I started with this approach when I built our tooltip library for my company, but eventually there were just too many gotchas. We switched to using JavaScript and inserting the generated element as a child of `body`.