我很難找出如何解決一些jQuery動畫隊列問題......我試圖讓一個手風琴像畫廊,擴展div的是徘徊在和同時,增加同一個div的標籤區域的高度,同時縮小所有其他的畫廊div。我嘗試了所有可以在網上找到的.stop(),.stop(true,true)和一個名爲hoverFlow的插件。請,誰能幫我解決這個問題?問題與jQuery動畫隊列
這裏所有到目前爲止,我已經得到了代碼:
.sect{
float: left;
width: 190px;
height: 400px;
cursor: pointer;
overflow: hidden;
}
#s1{ background-color: #006600; }
#s2{ background-color: #993300; }
#s3{ background-color: #3333CC; }
#s4{ background-color: #FF6600; }
#s5{ background-color: #FFCC00; }
.legend{
height: 50px;
margin-top: 330px;
background-color: #000000;
color: #fff;
padding: 10px;
font-weight: bold;
font-size: 14px;
overflow: hidden;
}
.legend img{
vertical-align: middle;
padding-right: 5px;
}
.legend p{
display: none;
font-weight: normal;
}
#s1{
border-top-left-radius: 20px;
-moz-border-radius-topleft: 20px;
border-bottom-left-radius: 20px;
-moz-border-radius-bottomleft: 20px;
}
#leg1{
border-bottom-left-radius: 20px;
-moz-border-radius-bottomleft: 20px;
}
#s5{
border-top-right-radius: 20px;
-moz-border-radius-topright: 20px;
border-bottom-right-radius: 20px;
-moz-border-radius-bottomright: 20px;
}
#leg5{
border-bottom-right-radius: 20px;
-moz-border-radius-bottomright: 20px;
}
$(function(){
var sectNumber;
$('.sect').hover(function(){ // <--------- MOUSE OVER
// Recover selected section's id
sectNumber = $(this).attr('id');
// Resize all the sections that were not selected (shrink)
$('div.sect').each(function(){
if($(this).attr("id") != sectNumber){
$(this).stop().animate({width: 50}, 500);
$(this).find('div.legend').fadeOut(200);
}
});
// Increase width of selected section
$(this).stop().animate({width: "750"}, 500);
// Incerase height of selected section's legend
$(this).find('div.legend').stop().animate({height: 100, marginTop: 280}, 500);
// Show legend description
$(this).find('div.legend').find('p').fadeIn(500);
}, function(){ // <--------- MOUSE OUT
// Resize all the sections that were not selected (expand)
$('div.sect').each(function(){
if($(this).attr("id") != sectNumber){
$(this).stop().animate({width: 190}, 500);
$(this).find('div.legend').fadeIn(700);
}
});
// Reduce width of selected section
$(this).stop().animate({width: 190}, 500);
// Reduce height of selected section's legend
$(this).find('div.legend').stop().animate({height: 50, marginTop: 330}, 500);
// Hide legend description
$(this).find('div.legend').find('p').fadeOut(500);
});
});
<div id="accordion">
<div id="s1" class="sect">
<div class="legend" id="leg1">
Section 1 Header
<p>
Description Line 1<br/>
Description Line 2
</p>
</div>
</div>
<div id="s2" class="sect">
<div class="legend" id="leg2">
Section 2 Header
<p>
Description Line 1
</p>
</div>
</div>
<div id="s3" class="sect">
<div class="legend" id="leg3">
Section 3 Header
<p>
Description Line 1
</p>
</div>
</div>
<div id="s4" class="sect">
<div class="legend" id="leg4">
Section 4 Header
<p>
Description Line 1
</p>
</div>
</div>
<div id="s5" class="sect">
<div class="legend" id="leg5">
Section 5 Header
<p>
Description Line 1
</p>
</div>
</div>
</div>
jsFiddled代碼:http://jsfiddle.net/gnarf/UspJ6/ – gnarf 2011-03-11 17:40:41
你已經嘗試過尋找[現有的畫廊,這是否](http://www.google.com/search?q=jquery+accordion+gallery)?那裏有一噸**的jQuery插件插件。 – 2011-03-11 17:41:02
@gnarf:將您的演示添加到問題:) – 2011-03-11 17:42:18