I dont know how familiar you are with CSS and JS, but you can do 2 things:
1.
Use a div in the root of the body element, with position:absolute
or position:fixed
(Depending on your design and layout) and z-index:-100
or whatever is needed to hide it, and then use JS or jQuery to change z-index to make it visible.
2.
Get the button to insert and remove the element into the DOM at root much like the first solution, from a string directly.
1
solved HTML Button that opens a panel [closed]