title: jQuery animate horizontal slide across page
body: <p>Hey all, another interesting one,</p>
  
  <p>I'm building a menu that will slide across the entire width of the page (width:100%;) and need some help. I have an arrow button floating on the right side of the page that will trigger a menu bar to slide out when clicked. I'd like the arrow button to slide out in front of it and once all the way across change the arrow image to it's opposite file.</p>
  
  <p>The big issue is that the width and height of these need to be flexible to allow for varying content. I've got a feeble attempt at making it work, but I know that I'm missing a whole lot of factors here. My code doesn't even touch moving the arrow button along with the rest.. and that's not for lack of effort!</p>
  
  <p>Any help? Thank you!</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="main"&gt;
       &lt;div class="trans" id="trigger"&gt;
            &lt;img class="arrow_small" src="images/left_small.png" alt="slide out menu" /&gt;
       &lt;/div&gt;
       &lt;div id="slider"&gt;
            &lt;div class="trans" id="overlay"&gt;&lt;/div&gt;
            &lt;div id="content"&gt;
                 &lt;p&gt;this is the content&lt;/p&gt;
            &lt;/div&gt;
       &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>#main {
      width:100%;
      height:306px;
      top:50%;
      margin-top:-153px;
      position:absolute;
  }
  #trigger {
      width:30px;
      height:100%;
      float:right;
      background-color:#000;
      position:relative;
      z-index:3;
  }
  .arrow_small {
      position:absolute;
      left:50%;
      top:50%;
      margin-left:-6px;
      margin-top:-12px;
  }
  #overlay {
      width:100%;
      height:100%;
      position:absolute;
  }
  #content {
      width:100%;
      height:100%;
      position:absolute;
      z-index:2;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$(document).ready(function(){
  //hide functions
      $('#slider').css('display', 'none');
  //menu slide out
      $('#trigger').click(function (){
          var bar = $('#slider');
              bar.show(function(){
                  this.animate({'marginRight':'100%'},1000);
              });
      });
  });
  </code></pre>