title: CSS - right align block with edge of viewport, but with a limit
body: <p>I have a header bar with a coloured background and some right-aligned menu items inside. The header bar should stretch the full width of the viewport, with a minimum width to avoid shrinking to below the (fixed) width of the main body of the site. The menu items inside should remain right aligned with the main body of the site even when the header bar extends wider. So far so easy: <a href="http://jsfiddle.net/symposion/fgrGD/" rel="nofollow">http://jsfiddle.net/symposion/fgrGD/</a></p>
  
  <pre><code>&lt;div class="headerBar"&gt;
    &lt;div class="headerMenu"&gt;
      Some item
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="mainContent"&gt;
  &lt;/div&gt;
  
  .headerBar {
    margin-top:30px;
    background-color:black;
    color:white;
    min-width:400px;
    padding-top:10px;
    padding-bottom:10px;
  }
  
  .headerMenu {
    text-align:right;
    max-width:400px;
    margin-left:auto;
    margin-right:auto;
  }
  
  .mainContent {
    width:400px;
    margin-left:auto;
    margin-right:auto;
    background-color:blue;
    height:100px;
  }
  </code></pre>
  
  <p>Where it gets complicated is that I'd <em>also</em> like the menu to move left (while still remaining right aligned to the edge of the screen) when the browser is resized smaller than the minimum width of the main site, to make best use of the remaining space. The naive way of doing this is to remove the min-width from the header bar, but this obviously means that you end up with a nasty blank gap when you scroll over to the right.</p>
  
  <p>Constraints:</p>
  
  <ul>
  <li>I can't make the header a fixed height, it needs to expand and contract based on its content</li>
  <li>No JS</li>
  <li>Ideally I'd like to avoid lots of redundant markup in the header; I can live with a little if it's the only way.</li>
  <li>Needs to work in IE8+, Firefox, Chrome, Safari, iOS</li>
  </ul>
  
  <p>Any ideas?</p>