如何使用jquery缓慢地为div的宽度设置动画

Ram*_*ind 3 javascript jquery animation

我的导航嵌套在左侧屏幕的div中,当用户向下滚动页面并到达像素296时,左侧导航缓慢显示,其宽度朝向右侧增长.

我现在拥有的是半工作.当用户向下滚动页面时,会出现嵌套在div中的导航,但我希望它能够向右慢慢动画并且不会发生.不确定我做错了什么.我遇到问题的具体方法是:

$("#slidebottom").animate({ width: "100" }, 'slow');
Run Code Online (Sandbox Code Playgroud)

但这是我的整个代码:

$(window).scroll(function(){

  var wintop = $(window).scrollTop(), docheight = $(document).height(), 
  winheight =    $(window).height();

  var bottomHeight = $("#slidebottom").height();
  var zeroheight = 0;

  if  (wintop > 296) {
    bottomHeight = $('#slidebottom').height(docheight);
    $("#slidebottom").animate({ width: "100" }, 'slow');

  }

  if( wintop < 296)
  {
    bottomHeight = $('#slidebottom').height(zeroheight);    
    //$("#slidebottom").animate({ width: "0" }, 'slow');
  }
});
Run Code Online (Sandbox Code Playgroud)

pre*_*lna 6

jQuery的文档显示整数,而不是字符串,作为参数宽度:

$("#slidebottom").animate({ width: 100 }, 'slow');
Run Code Online (Sandbox Code Playgroud)

编辑:所以我错了,那不是问题; 它也处理字符串.