Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 将长度添加到';幻灯片'';左';_Jquery_Jquery Ui - Fatal编程技术网

Jquery 将长度添加到';幻灯片'';左';

Jquery 将长度添加到';幻灯片'';左';,jquery,jquery-ui,Jquery,Jquery Ui,我想知道如何编辑div向左滑动的方向量。到目前为止,我只编辑“tween”或“slide”效果,我希望幻灯片的效果是500px和停止 一种方法是按所需的像素数设置边距的动画 $("element").animate({marginLeft : "-20px"}, 500); 注:“幻灯片”通常用于元素的完整宽度/高度。您可以尝试设置距离参数,但它不会给您想要的效果 <script> $("#hide").click(function(){

我想知道如何编辑div向左滑动的方向量。到目前为止,我只编辑“tween”或“slide”效果,我希望幻灯片的效果是
500px和停止


一种方法是按所需的
像素数
设置
边距
的动画

$("element").animate({marginLeft : "-20px"}, 500);
注:
“幻灯片”
通常用于元素的完整
宽度/高度。您可以尝试设置
距离
参数,但它不会给您想要的效果

     <script>
      $("#hide").click(function(){
         $(".target").hide( "slide", 
                     { direction: "down" ,
                       distance: "200px" }, 2000 );
      });

      $("#show").click(function(){
         $(".target").show( "slide", 
                      {direction: "up" }, 2000 );
      });



      });
       </script>
       <style>
          p {
               background-color:#bca;
               width:200px; 
               border:1px solid green; 
            }
         div{ width:100px; 
                height:100px; 
                background:red;  
            }
      </style>
    </head>
    <body>

   <p>Click on any of the buttons</p>
   <button id="hide"> Hide </button>
   <button id="show"> Show</button> 

   <div class="target">
   </div>

$(“#隐藏”)。单击(函数(){
$(“.target”).hide(“幻灯片”,
{方向:“向下”,
距离:“200px”},2000);
});
$(“#显示”)。单击(函数(){
$(“.target”).show(“幻灯片”,
{方向:“向上”},2000年);
});
});
p{
背景色:#bca;
宽度:200px;
边框:1px纯绿色;
}
div{宽度:100px;
高度:100px;
背景:红色;
}
单击任意按钮

隐藏 显示
为什么不使用.animate,用show将其滑动到CSS中给定的宽度。
     <script>
      $("#hide").click(function(){
         $(".target").hide( "slide", 
                     { direction: "down" ,
                       distance: "200px" }, 2000 );
      });

      $("#show").click(function(){
         $(".target").show( "slide", 
                      {direction: "up" }, 2000 );
      });



      });
       </script>
       <style>
          p {
               background-color:#bca;
               width:200px; 
               border:1px solid green; 
            }
         div{ width:100px; 
                height:100px; 
                background:red;  
            }
      </style>
    </head>
    <body>

   <p>Click on any of the buttons</p>
   <button id="hide"> Hide </button>
   <button id="show"> Show</button> 

   <div class="target">
   </div>