http://jsfiddle.net/7vwcz/如何将元素滑动到一起?
所以我试图在工具栏中制作一系列图标,这里用小彩色方块表示。
前两个对比度和对比度2将具有用于控制事物的弹出式滑块。我只是想让图标平滑地移动,然后平滑地放回原位。我现在将动画设置为低速,这样我们就可以看到发生了什么。正如你所看到的,它们移动不正常而且不正确 - 你可以通过点击红色正方形来看到动作。
我在做什么错?
$('#contrastSlider').slider();
$('#contrastSlider').hide()
$('#contrast').click(function() {
var cs = $('#contrastSlider'),
w = cs.outerWidth(true);
if (!cs.is(':visible')) {
$('#about').css('margin-left', -w + 40);
$('#contrast2').css('margin-left', -w);
w = 0;
}
cs.toggle("slide", 2000);
$('#contrast2').animate({
'margin-left': -w
}, 2000, function() {
this.style.marginLeft = 0;
});
$('#about').animate({
'margin-left': -w + 40
}, 2000, function() {
this.style.marginLeft = 0;
});
});
之前更新了小提琴,错误的链接。 – Aerovistae 2013-03-13 20:36:26
你想要做这样的事吗? http://jsfiddle.net/JzRsG/ – 2013-03-13 20:51:53
再次回到原来的位置,是的!这是怎么回事... – Aerovistae 2013-03-13 20:52:18