Reputation: 702
I am creating a website where the main layout is something like this:
<div id="container" style="height: 100%;">
<div id="content">
Text goes here
</div>
</div>
I have made it so that the content div is always vertically and horizontally centered within the container. I have triggered the centering at window.onload
and window.onresize
. I thought it was ok until I realised when I pinch zoom on Chrome for Android (haven't tried other browsers yet) it does not call window.onresize
and my layout becomes totally messed up until window.onresize
is called.
(I want to try not to use setInterval to center the content as it will either not be instant or not be very efficient.)
I was wondering if there was a Javascript function which is executed everytime the user zooms or if there were any variables which will change as the user zooms.
Upvotes: 3
Views: 301
Reputation: 702
window.innerWidth
and window.innerHeight
change when the user zooms.
Upvotes: 1