使用jQuery从右向左滑动DIV [英] Slide DIV Right to Left with jQuery

查看:1469
本文介绍了使用jQuery从右向左滑动DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery代码在加载时从左到右为div设置动画,然后通过单击关闭按钮div从右到左隐藏。它工作正常,它只是不左对水平但对角线。我究竟做错了什么?以下是我使用 http://jsfiddle.net/N8NpE/2/ 的代码示例

I'm using jQuery code to animate a div from left to right on load, and then by clicking the close button the div hides from right to left. It's working fine, it's just not going left to right horizontally but diagonally. What am I doing wrong? Here's an example of the code I'm using http://jsfiddle.net/N8NpE/2/

$(function(){
    $("#content-box").hide(0).delay(0).show(500);
});

$(function(){
    $("#ClosePanel").click(function () {
        $("#content-box").hide("slow");
    });
});

任何帮助将非常感激。

推荐答案

您可以尝试使用 .animate(),而不是 .hide() .show()。这将给你一些更多的控制一切。

You could try using .animate() instead of .hide() and .show(). This will give you a little more control over everything.

$("#content-box").animate({'width': 240},500);

要关闭,请包含回调函数,以便在动画后将显示设置为none:

And to close, include a callback function to set display to none after the animation:

$("#content-box").animate({'width': 0},500,function(){
       $("#content-box").css('display','none');
});

http://jsfiddle.net/N8NpE/6/

这篇关于使用jQuery从右向左滑动DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆