2 回答

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊
這就是我認(rèn)為你可以做到的。您檢查該類(lèi)是否已應(yīng)用并根據(jù)此添加動(dòng)畫(huà)。
feather.replace();
$(document).ready(function() {
$(".response_menu_icon").click(function() {
if($(".sidebar1").hasClass("sidebar_menu")){
$(".sidebar1").addClass("animate__slideOutRight");
setTimeout(function(){$(".sidebar1").toggleClass("sidebar_menu");},200);
} else {
$(".sidebar1").removeClass("animate__slideOutRight");
$(".sidebar1").addClass("sidebar_menu");
$(".sidebar1").addClass("animate__slideInRight");
};
//$(".sidebar1").addClass("animate__slideOutRight");
});
//
$(".response_more_icon").click(function() {
$(".area1").toggleClass("area_more");
});
});
動(dòng)畫(huà)播放完畢后,我使用設(shè)置的超時(shí)時(shí)間刪除類(lèi)。

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊
您可以使用 jQuery 或 JS 添加您的類(lèi),并讓您的 CSS 處理您向新位置的過(guò)渡。
例如:
你有一個(gè)側(cè)邊欄,當(dāng)點(diǎn)擊一個(gè)按鈕打開(kāi)然后再次點(diǎn)擊關(guān)閉。
側(cè)邊欄 CSS 將具有側(cè)邊欄起點(diǎn)(即位置)。然后你可以為你要添加到你希望元素等的結(jié)束位置的其他類(lèi)設(shè)置樣式。
?//starting position is hidden off the screen
#sidebar{
? ? position: absolute;
? ? top: 0px;
? ? left: -250px;
? ? width: 250px;
? ? height: 100vh;
? ? background-color: blue;
? ? transition: ease left .3s;
}
//brings the element into view when opened
#sidebar.toggled{
? left: 250px;
}
然后,您可以根據(jù)需要單擊按鈕添加課程。
添加回答
舉報(bào)