title: Position a Div "Fixed" Vertically and "Absolute" Horizontally within a "Position:Relative" Container Div
body: <p>I'm looking for a way I can create a div which will be fixed on the page vertically, so if the user scrolls down, the div stays at the same place on the page. But have it positioned absolutely horizontally, so if the users screen is narrower than my webpage, scrolling to the right or left will not cause the div to move with the screen and, in some cases, remain either half visible at the edge of the screen or off the page completely.</p>
  
  <p>This div must be within a "Position:Relative" Div.</p>
  
  <p>I'm fairly sure there is no way to assign different positions to the varying axis of a div but this is the best way to describe the effect which I am hoping to achieve.</p>
  
  <p>I have this so far, which is basically just a Fixed Div within a Relative Div.</p>
  
  <p><strong>CSS</strong></p>
  
  <pre><code>#container {
  position:relative;
  width:700px;
  height:1000px;
  top:50px;
  left:50px;
  background-color:yellow;
  }
  
  #blue-box{
  position:fixed;
  width:100px;
  height:100px;
  background-color:blue;
  margin-top:20px;
  margin-left:400px;
  {
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div id="container"&gt;
  &lt;div id="blue-box"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have also created a <a href="http://jsfiddle.net/zhQkq/1/">jsFiddle</a> to help demonstrate the problem.</p>
  
  <p>This works fine for the vertical, but if you resize your web-browser so that it is narrower than the yellow box (container) and then scroll horizontally, the blue box will move with the page. I'm hoping to stop that from happening.</p>
  
  <p>If there is no way to achieve this through CSS, I'm perfectly happy to use JavaScript as long as it works with all modern browsers and both IE7 and IE8. (Which is why I have added the JavaScript tag)</p>
  
  <p>Can anyone help me out?</p>