Note that there are some explanatory texts on larger screens.

plurals
  1. POAbsolute elements offset in landscape orientation
    text
    copied!<p>My page when viewed on a mobile browser (tested on Android JB and iOS 6) renders fine when initially loaded in both portrait and landscape modes. However, when I go <strong>from landscape to portrait</strong> the absolute positioned divs are offset from where they should actually be. The weird part is that if I am zoomed in when I change the orientation this problem doesn't manifest.</p> <p>This is same as the problem mentioned here: <a href="https://stackoverflow.com/questions/8254774/strange-offset-in-the-css-element-position-after-changing-orientation-on-ipad">Strange offset in the CSS element position after changing orientation on iPad</a> only difference being I am testing on a phone. I tried the solutions provided there but they don't seem to work.</p> <p>Here is my CSS</p> <pre><code> html{ width: 100%; height: 100%; } body{ position: relative; overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; background: #000; } #container{ position: relative; width: 100%; height: 100%; margin: 0; padding: 0; min-width: 960px; min-height: 544px; } #pic{ display: table; height: 100%; width: auto; margin: 0 auto; z-index: 5; } #links{ position: absolute; width: 100%; height: 50px; bottom: 5px; left: 0; right: 0; z-index: 9; background: #ccc; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)"; filter: alpha(opacity=10); -moz-opacity: 0.1; -khtml-opacity: 0.1; opacity: 0.1; } #wrapper{ position: absolute; width: 100%; height: 50px; bottom: 5px; left: 0; right: 0; z-index: 12; } #content{ display: table; width: 100%; height: 100%; margin: 0 auto; } #content div{ display: inline-block; *display: inline; zoom: 1; width: 20%; text-align: center; } #content div *{ vertical-align: middle; border: 0; text-decoration: none; color: #000; border-radius: 5px; } /* portrait */ @media screen and (orientation:portrait) { #container{ position:relative; width: 100%; height: 100%; margin: 0; padding: 0; min-width: 960px; min-height: 544px; } } /* landscape */ @media screen and (orientation:landscape) { #container{ position:relative; width: 100%; height: 100%; margin: 0; padding: 0; min-width: 960px; min-height: 544px; } } </code></pre> <p>As you can see I have tried the solution from the other question which doesn't work. And my HTML structure</p> <pre><code>&lt;div id="container"&gt; &lt;img src="pic_jj.jpg" alt="image" id="pic" /&gt; &lt;div id="links"&gt; &lt;/div&gt; &lt;div id="wrapper"&gt; &lt;div id="content"&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>You can view my page <a href="http://jeevanjose.com" rel="nofollow noreferrer">here</a> if you need a live demo. I should probably mention that I am looking for a non-js solution.</p> <p>PS. I am using this meta tag: </p> <pre><code>&lt;meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no;"&gt; </code></pre> <p><strong>Update</strong> Screenshots.</p> <blockquote> <p>Here is what the initial load looks like (normal behaviour) <img src="https://i.stack.imgur.com/fBoTL.png" alt="enter image description here"></p> <p>Here's what happens when I change the orientation <strong>from landscape to portrait</strong> <img src="https://i.stack.imgur.com/rce7k.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/uKWaA.png" alt="enter image description here"></p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload