2012-01-17 71 views

回答

1

请使用.animate()的宽度减少到0动画:

$('#my-id').animate({ width : 0 }, 1000); // slide left the div 

滑块向右更复杂......

0

如果您的div有溢出这可以工作:隐藏

$("#test").animate({width:0},500,function(){$(this).hide()}) 
+0

如果您的div有边框,您需要特别隐藏。如果没有,你可以使用@ WouterJ的解决方案 – 2012-01-17 22:21:10

3

这是一个快速的jQuery插件,可能有帮助吗?

jQuery.fn.slideLeftHide = function(speed, callback) { 
    this.animate({ 
     width: "hide", 
     marginLeft: "hide", 
     marginRight: "hide" 
    }, speed, callback); 
} 

jQuery.fn.slideLeftShow = function(speed, callback) { 
    this.animate({ 
     width: "show", 
     marginLeft: "show", 
     marginRight: "show" 
    }, speed, callback); 
} 

要使用像这样:

$("#elemID").slideLeftHide(300); 

和示范开始一个FIDDLE