mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-09-10 03:37:11 +02:00
Added dynamic submenus
This commit is contained in:
@@ -105,4 +105,12 @@ h3.footer-title{
|
||||
top: 0;
|
||||
left: 100%; /* Positioniert das Submenü rechts vom Hauptmenü */
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.dropdown-menu.collapse {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dropdown-menu.collapse.show {
|
||||
display: block;
|
||||
}
|
21
app/static/js/close-submenus.js
Normal file
21
app/static/js/close-submenus.js
Normal file
@@ -0,0 +1,21 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const dropdownSubmenus = document.querySelectorAll('.dropdown-submenu > .dropdown-item');
|
||||
|
||||
dropdownSubmenus.forEach((submenu) => {
|
||||
submenu.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
const targetMenu = document.querySelector(submenu.getAttribute('data-bs-target'));
|
||||
const allSubmenus = document.querySelectorAll('.dropdown-menu.collapse');
|
||||
|
||||
// Schließe alle anderen Submenüs
|
||||
allSubmenus.forEach((menu) => {
|
||||
if (menu !== targetMenu) {
|
||||
menu.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle des aktuellen Submenüs
|
||||
targetMenu.classList.toggle('show');
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user