2009-08-13 41 views
0

我用下面的代码获取手风琴发生:jQuery的手风琴:的div滚动条不滑动很好

$(".accordion h2").eq(2).addClass("active"); 
$(".accordion-content").eq(2).show(); 
$(".accordion h2").click(function(){ 
    $(this).next(".accordion-content").slideToggle("slow") 
    .siblings("div:visible").slideUp("slow"); 
    $(this).toggleClass("active"); 
    $(this).siblings("h2").removeClass("active"); 
}); 
$("div.accordion-content").hide(); 
$("h2#open").trigger('click'); 

但是,单击H2时影响手风琴,如果“手风琴内容之一“divs有一个滚动条(CSS设置为溢出:自动),div似乎是重叠的,而不是很好的动画。有没有一种方法可以设置“overflow:auto”只有在div完全可见之后才会发生?或者任何其他方式呢? 谢谢。

回答

1

你可以尝试使用changestart和change事件,它们在动画前和动画后发射。 ui.newContent应该是有问题的div。

粗糙2秒演示here.

$('.selector').accordion({ 
    changestart: function(event, ui) { 
     ui.newContent.css('overflow' , 'hidden'); 
    }, 
    change: function(event, ui) { 
    ui.newContent.css('overflow' , 'auto'); 
    } 
}); 
+0

由于resquare。虽然从演示的外观来看,你的手风琴和我的手风琴一样动作不错 - 这里有重叠现象... – lnvrt 2009-08-13 09:07:50

+0

啊,在Chrome浏览器中看起来不错,你看到了哪个浏览器的重叠? – redsquare 2009-08-13 09:42:05

+0

hmmm在FF3.5.2中看起来很严峻! – redsquare 2009-08-13 09:42:53