Is it possible to show elements of an unordered list in a two-column submenu using CSS? I want to achieve something like this, but without having several <div>s in the submenu. I tried this, but I have two issues:
- The submenu items do not align if they are of different widths (obvious) and I would like to keep that as it is because I do not know the length of each item
- I cannot keep the top menu selected when hovering over it
How can I fix these issues?
You can use
min-widthfor sub-menu li and so it would align or expand as per the contents.Define a class
.activeas below in your cssAnd Try below script,
DEMO