Currently, I am working on a menu that has drop-down items that appear when the user hovers over them.
Here is what I am aiming for:
- I want the dropdown to be contained within the parent element so I can use the :hover pseudo-class to show it.
- The dropdown should span 100% of the window width, not just its parent's width.
- I do not want the contents of the dropdown to be positioned relative to the parent menu item.
- The CSS triangle should point towards the middle of the parent menu item.
- I also want to add a CSS transition to smoothly fade in the menu and move it into position.
For reference, here is a quick layout similar to what I am working on: http://jsfiddle.net/kn3Z3/2/
In attempting to keep the dropdown inside the parent element, I set the parent element's position: static
. However, this presents an issue as I now lack a reference point to position the CSS triangle.
I cannot hard code the position of the dropdown for each menu item due to the dynamic nature of the menu and changes in font size with media queries (as seen in the fiddle).
I have explored other solutions where the triangle was integrated into the parent menu item itself. This approach hindered the animation synchronization with the menu and led to poorer performance.
If anyone has any ideas on how to achieve this or if you believe this animation method is not feasible, please share your thoughts.
As a side note, I also tested the 100% width solution mentioned here: Dropdown Menu - Make the <ul> submenu 100% width; however, I require the contents of the dropdown to not align relatively to the parent menu item.