我想使滑塊面板從右邊界屏幕向左滑動。 當我「懸停」面板調用者:選項卡時,我希望幻燈片開始移動。當面板移動時,它會推動標籤。我有這樣的代碼:使用jQuery和css3水平滑動面板
HTML
<div id="panel">
<div class="content"><!-- Content --></div>
</div>
<div id="tab">hit me for show panel</div>
CSS
#tab {
width:50px;
height:150px;
position:fixed;
right:0px;
top:100px;
display:block;
cursor:pointer;
}
#panel {
position:fixed;
right:0px;
top:50px;
background-color:#999999;
height:500px;
width:0;
}
#panel .content {
width:290px;
margin-left:70px;
}
jQuery的
$(function() {
$('#tab').hover(function(event) {
var panel = $('#panel');
if (panel.hasClass('open')) { //condition error
panel.removeClass('open');
$('.content').fadeOut('slow', function() {
$('#panel').stop().animate({
width: '0',
opacity: 0.0
}, 500)
})
} else {
panel.addClass('open');
$('#panel').stop().animate({
width: '400',
opacity: 1
}, 500, function() {
$('.content').fadeIn('slow');
});
}
});
});
問題是,當我離開的標籤用鼠標光標 「懸停」 面板,面板消失。只要我將鼠標懸停在標籤和麪板上,我希望面板保持打開狀態。我如何做到這一點?
編輯答案。讓我知道它是否適合你 –