title: HTML5 video fit width OR height
body: <p>The <code>width=100% height="auto"</code> scales my videos to fit the whole width of the browser window, but if the height of the window is lower than the aspect ratio the video gets cropped in height.</p>
  
  <p>I want the video to scale to fit either width or height so that I can always see the whole video without crop, filling the closest ratio (adding empty space to sides if window ratio is lower).</p>
  
  <p>I can't figure out how to do this however. <br>
  First any height value, % or px, seems to be disregarded, I can't set the size at all using height, only width. Same for min-width/height.</p>
  
  <p>How can this be done?</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;video id="video" width=100% height="auto" onclick=playPause()&gt;&lt;/video&gt;
  </code></pre>
  
  <p>Video is loaded by javascript where v is a video link from an array:</p>
  
  <pre><code>video.addEventListener('play', function() { v.play();}, false);
  </code></pre>