title: On scroll animate menu
body: <p>I m trying to create in jquery top menu, with height depending on window scroll position. When I use $(selector).css("height", "value"); everything is ok but when I try do this by animate it does not work correct. Here is my code. Thanks for your help.</p>
  
  <pre><code>&lt;!DOCTYPE   html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;style&gt;
  &lt;/style&gt;
  &lt;body&gt;
      &lt;nav style="background-color:red; height:100px;" class="navbar-fixed-top navbar navbar-default my-navbar"&gt;
      &lt;/nav&gt;
      &lt;div style="width:100%; height:2000px; background-color:blue;" class="content"&gt; 
      &lt;/div&gt;
  
      &lt;script&gt;
          $(document).ready(function(){
              $(window).scroll(function(){
                  var top=$(window).scrollTop();
                  if(top&gt;10){
                      $(".my-navbar").animate({height: '50px'}, "slow");
                  }else{
                      $(".my-navbar").animate({height: '100px'}, "slow");
                  }
              })
          })
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>