所以這個問題可能上面措辭很差,但是,讓我試着在這裏澄清一下。我有一個分成多個部分的html頁面。我有一個右側和左側部分,並在每個部分我有divs進一步分裂的事情。其中一個div稱爲rscontent,它擁有右側的內容,並且我有一個鏈接,一旦點擊就必須關閉rscontent中的所有內容。這是這樣的代碼:使用javascript點擊褪色?
$('section#rightpanel').on('click', 'a#rsclose', function (event) {
var $_closer = $(this);
var $_sectionNav = $('header.sectionNav'); // needs to adjust size
var $_sectionBody = $('section#body'); // needs to adjust size
var $_rightpanel = $('section#rightpanel'); // needs to collapse this
if ($_rightpanel.is('.collapsed')) {
// is closed, so open it
$_rightpanel.removeClass('collapsed').find('.rscontent').show();
$_sectionBody.css('width', '56%');
$_rightpanel.css('width', '34%');
$_closer.html('Close');
} else {
// is open, so close it
$_rightpanel.addClass('collapsed').find('.rscontent').hide();
$_sectionBody.css('width', '90%');
$_rightpanel.css('width', '2.8%');
$_closer.html('Open');
} // collapsed
return false;
});
現在這個工程,但我的問題是我如何添加淡入淡出效果,使關閉不會發生在一瞬間。我從我的CSS代碼,但我不知道如何使用它。
.fade {
-webkit-transition: all 500ms linear;
-moz-transition: all 500ms linear;
-o-transition: all 500ms linear;
-ms-transition: all 500ms linear;
}
任何人都知道如何做到這一點。我希望這個問題是有道理的。提前致謝!
謝謝。這正是我需要的 – Andy