我使用 html、css 和 JavaScript 創(chuàng)建了一個(gè)模態(tài),其代碼包含在片段中。你會(huì)注意到當(dāng)一個(gè)模態(tài)窗口打開(kāi)時(shí),它有一個(gè)從頂部滑動(dòng)的動(dòng)畫。我想讓模態(tài)窗口在關(guān)閉時(shí)具有滑動(dòng)到底部的動(dòng)畫(而不是在其位置時(shí)立即消失)有人可以調(diào)整代碼以達(dá)到預(yù)期的效果嗎?提前致謝!let open_modals = [];(function() { // Get the button that opens the modal // read all the control of any type which has class as modal-button var btn = document.querySelectorAll(".modal-button"); // All page modals var modals = document.querySelectorAll('.modal'); // Get the <span> element that closes the modal var spans = document.getElementsByClassName("close"); // When the user clicks the button, open the modal for (var i = 0; i < btn.length; i++) { btn[i].onclick = function(e) { e.preventDefault(); modal = document.querySelector(e.target.getAttribute("href")); modal.style.display = "block"; open_modals.push(modal.id); } } // When the user clicks on <span> (x), close the modal for (var i = 0; i < spans.length; i++) { spans[i].onclick = function() { for (var index in modals) { if (typeof modals[index].style !== 'undefined' && modals[index].id == open_modals[open_modals.length - 1]) { modals[index].style.display = "none"; open_modals.pop(); } } }}})();
為關(guān)閉模態(tài)窗口啟用向下滑動(dòng)動(dòng)畫
慕工程0101907
2021-09-30 09:33:10