謝謝你的小提琴樣品。請參見下面的代碼來解決問題:
HTML:
<div id="wrapper">
<div id="panelHolder">
<div class="panel" id="fullTimeSection">Content 1!</div>
<div class="panel" id="sixthFormSection">Content 2!</div>
<div class="panel" id="partTimeSection">Content 3!</div>
</div>
<nav role="category-navigation" id="catNav">
<ul id="menu-sections" class="section-menu">
<li class="menu-item" data-id="fullTimeSection"><a href="#">Full Time</a></li>
<li class="menu-item" data-id="sixthFormSection"><a href="#">Sixth Form</a></li>
<li class="menu-item" data-id="partTimeSection"><a href="#">Part TIme</a></li>
</ul>
</nav>
</div>
CSS:
#wrapper {width:100%; padding:0; position:relative; height:250px; margin-top:250px;}
#catNav ul {list-style-type:none; padding:0; margin:0;}
#catNav li {width:100px; display:inline-block; border:1px solid red;}
#panelHolder {position:absolute; top:-190px; width:100%; height:190px; overflow:hidden;}
.panel{width:94%; height:170px; padding:10px 3%; color:white; position:absolute; top:190px;}
.panel#fullTimeSection {background:#870057;}
.panel#sixthFormSection {background:#232323;}
.panel#partTimeSection { background:#555555;}
JS:
$('.menu-item').hover(
function() {
var panel = $('#' + $(this).data('id'));
var captionHeight = panel.height();
captionHeight = parseInt(captionHeight, 10);
var topHeight = 190 - captionHeight;
var topHeight =+ topHeight + 'px';
panel.stop().animate({ top: topHeight }, 500);
},
function() {
$('#' + $(this).data('id')).animate({ top: '190px' }, 500);
}
);
和小提琴:
http://jsfiddle.net/QE67u/10/
我希望這是你想要什麼。
編輯
我想你可以牽住菜單面板,直到你不選擇其他菜單塊。請參見下面的示例代碼和小提琴,當然:
$('.menu-item').hover(
function() {
$('.panel').animate({ top: '190px' }, 500);
var panel = $('#' + $(this).data('id'));
var captionHeight = panel.height();
captionHeight = parseInt(captionHeight, 10);
var topHeight = 190 - captionHeight;
var topHeight =+ topHeight + 'px';
panel.stop().animate({ top: topHeight }, 500);
}
);
http://jsfiddle.net/QE67u/14/
顯示你的HTML代碼,請。如果你在FIDDLE http://jsfiddle.net/上顯示你的問題會更好,(對你來說更舒適,以幫助我) – melvas
嗨梅爾維斯,用HTML編輯的原創 – Geoff
這裏是我的快速jsfiddle http://jsfiddle.net/QE67u/2/ – Geoff