title: how to get orientation:portrait mode with meta viewport with a fixed height
body: <p>time for my first own stackoverflowquestion, since this thing is driving me crazy the whole day now. i borrowed an ipad today to test a website wich comes with additional phone and an tablet-versions. (there's only safari on it) the layout is a comlete static thing with some graphics and they want it 1:1.
  so i learnd about mobile devices, added a </p>
  
  <pre><code>&lt;meta name="viewport" content="width=x" /&gt;
  </code></pre>
  
  <p>and got a perfect version for the phone. but when it comes to the tablet i ran into trouble.</p>
  
  <p>the tablet design i got is a vertical one. it has in this case 477x656 pixels. so it should fit in height and could show nice in every tablet, covering the whole display in portrait mode, beeing horizontally centered in landscape mode.</p>
  
  <p>so i thought i just put a </p>
  
  <pre><code>&lt;meta name="viewport" content="height=656" /&gt;
  </code></pre>
  
  <p>in the code and the browser renders the thing just as is does on the mobile version, just with our height as viewport-master instead of the width.
  this would be a perfect universial solution, solving the customers demands just as the phone version does.
  (well, of course the difference is, that you would scroll up and down in the phone version, while the tablet version would have some empty space left and right, especially in landscape-mode.)</p>
  
  <p>the css basicly is:</p>
  
  <pre><code>body {
      margin:0 auto;
      width:477px;
      height:656px;
  }
  </code></pre>
  
  <p>and the result is a total failure:</p>
  
  <ul>
  <li>in landscape mode the page is rendered vertically larger than the available space in the browser. (seems like height is ignored here)</li>
  <li>in portrait mode n massive amount of width is added to the html tag so that the body tag can only be seen half.</li>
  </ul>
  
  <p>adding my width to the viewport just makes the browser ignore the height and behave like it should in a phone-version.</p>
  
  <p>so i thought, i force html-width</p>
  
  <pre><code>html { max-width:477px !important; }
  </code></pre>
  
  <p>or so, but didn't help.
  so i thought, okay, forget it and workaround the portrait version using</p>
  
  <pre><code>html { margin:0 auto; }
  @media (orientation:portrait) { html { margin:0; }}
  </code></pre>
  
  <p>and so, after a lot of desperation, i found out that: <strong>adding a viewport-meta height=x forces the page to be landscape mode</strong></p>
  
  <p>this is basically (i guess) due to safari calculating the viewport-width according to the given height and the screen proportions (in landscape mode), instead of the given html. resulting in landscape proportions even in portrait mode... weird enough. and yeah - its not what you expect, looks like a browserbug to me. or am i totally wrong here, misunderstanding the whole viewport-thing?</p>
  
  <p>so</p>
  
  <ul>
  <li>how do i force the browser to get it right? to calculate the html-width according to my html/css based on my given height?</li>
  <li>and how do i get the full page shown in landscape mode? why the heck is it larger?</li>
  </ul>
  
  <p>any hints highly appreciated! (i'm indeed kinda physically exhausted now... turns out, that i'm not used anymore to software not doing what i expect)</p>
  
  <p>uhm, so here's my test-szenario to mess around with:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta name="viewport" content="height=656" /&gt;
  &lt;style&gt;
  html { background-color:#8b8b8b; }
  html { width:477px !important; }
  
  @media (orientation:landscape){
      html { margin:0 auto; background-color:#e1006e; }
      #p { display:none; }
  }
  @media (orientation:portrait){
      html { background-color:#8f9d6a; }
      #l { display:none; }
  }
  
  body {
      position:relative;
      background-color:#000;
      margin:0 auto;
      padding:0;
      width:477px;
      height:656px;
  }
  .container {
      margin:0 auto;
      width:477px;
      height:656px;
      background-color:#232529;
      color:#9bbe0a;
  }
  .content { padding:250px 0 0 45px; }
  
  .footer { position:absolute; left:22px; bottom:2px; }
  .footer, .footer a, .footer a:link, .footer a:visited, .footer a:hover, .footer a:active { color:#9bbe0a; }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container"&gt;
      &lt;div class="content"&gt;
          &lt;p&gt;stuff&lt;/p&gt;
          &lt;div id="l"&gt;&lt;b&gt;Landscape&lt;/b&gt;&lt;/div&gt;
          &lt;div id="p"&gt;&lt;b&gt;Portrait&lt;/b&gt;&lt;/div&gt;
          &lt;pre&gt;
  &lt;script type="text/javascript"&gt;
  document.write(
      '\r\rw.orientation: '+window.orientation+
      '\rscreen: '+screen.width+'x'+screen.height+
      '\rbody.client: '+document.body.clientWidth+'x'+document.body.clientHeight+
      '\rw.outer: '+ window.outerWidth+'x'+window.outerHeight+
      '\rw.inner: '+ window.innerWidth+'x'+window.innerHeight+
      '\rdocEl.client: '+document.documentElement.clientWidth+'x'+document.documentElement.clientHeight
  );
  &lt;/script&gt;
          &lt;/pre&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="footer"&gt;&lt;a href="#"&gt;blah&lt;/a&gt; | &lt;a href="#""&gt;blah&lt;/a&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>