I am drawing a canvas with a javascript function and it always aligns to windows size. I want to have a
<div>...</div>
Element overlay a canvas and be vertically and horizontically centered.
The only thing I came up was
position:absolue;
But then again
top:0;
left:0;
bottom:0;
right:0;
Only centers my element horizontically not vertically.
So I've changed it to.
left:calc(50% - *divwidth*/2);
top:calc(50% - *divheight*/2);
But it is not optimal and doesnt work for various windows sizes.
I think that this might not even be possible with pure css, so I am happy to use JS but how do I do that?