A user is on my webpage and has pressed a key. This key triggers a hidden div to become visible and display a message in the center of the screen.
On desktop browsers, I can achieve this easily:
.notif-div{
background-color: #000;
position:fixed;
top:50%;
left:50%;
z-index:60;
visibility: hidden;
}
This works great, even if the browser is zoomed.
However, in browsers on mobile devices, such as Chrome or Safari the iPad Pro - which permit an apparently special form of zooming - I have not yet found a method that is able to reliably place a div in the center of the user's screen.
Instead, the "centered" div is centered relative to some un-zoomed version of the page, but if the user is sufficiently zoomed, the div might be placed entirely out of their viewing window.
The same issue is true if, for example, I try to fix an element at the top or the bottom of the page - it works fine until a mobile user zooms.
Has anyone found a CSS or JavaScript solution to the mobile zooming problem?