Solved submenu bug

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-10 14:05:53 +01:00
parent 28cd3e1f2f
commit 9b8e9a0f1c
2 changed files with 32 additions and 0 deletions

View File

@ -137,3 +137,22 @@ h3.footer-title{
display: block; display: block;
opacity: 1; opacity: 1;
} }
.dropdown-submenu > .dropdown-menu {
position: absolute;
top: 0;
left: 100%; /* Standardmäßig rechts ausrichten */
margin-top: -1px;
z-index: 1050;
transition: opacity 0.3s ease-in-out;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
opacity: 1;
}
.dropdown-submenu > .dropdown-menu[style*="right: 100%"] {
left: auto; /* Überschreibt die linke Position, wenn nach links geöffnet */
}

View File

@ -9,6 +9,19 @@ document.addEventListener('DOMContentLoaded', () => {
clearTimeout(timeout); clearTimeout(timeout);
const menu = submenu.querySelector('.dropdown-menu'); const menu = submenu.querySelector('.dropdown-menu');
if (menu) { if (menu) {
// Dynamische Positionierung
const rect = menu.getBoundingClientRect();
const viewportWidth = window.innerWidth;
// Überprüfen, ob Platz nach rechts ist, sonst nach links öffnen
if (rect.right > viewportWidth) {
menu.style.left = 'auto';
menu.style.right = '100%';
} else {
menu.style.left = '100%';
menu.style.right = 'auto';
}
menu.style.display = 'block'; menu.style.display = 'block';
menu.style.opacity = '1'; menu.style.opacity = '1';
} }