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