Search code examples
javascripthtmlcssdrop-down-menusubmenu

Align drop-down submenu in navigation to the same height as its parent


I try to align drop-down submenu to the same level as its parent. I spend few hours solve this issue, but I still don't know how to go about that.

The blue buttons are navigation links when I click on one of them, dark-blue sub-menu appears, then when I click on a link inside dark-blue menu a pink sub-menu appears. Problem is that the pink sub-menu would appear at the same height as the li element that I clicked on. I want to have the pink sub-menu always appear at the top, aligned with the dark-blue menu.

I hope you understand. I attach 2 pictures. I would appreciate any help. Thank you.

Here is a link to the website. http://help.miloslacko.sk/ You can see the menu when you click on a link "01 SOCIALNE VECI MPSVR SR".

image1

image2


Solution

  • Change the position property of .wsmenu-submenu li to static.

    It is currently set to position: relative, which forces the children that are absolute anywhere beneath it to base their top off of it. Instead, allow the overall container (.wsmenu-submenu video-container) to be the nearest relative parent so that your absolute children base their position off of that.

    NOTE: position: absolute will also act as an anchor for absolute children, so you don't need to change anything else.