When I hover over a navigation menu item, it brings up 6 sub menu items. I want these sub-items to appear in two blocks of 3 that are adjacent to each other.
I tried using display: flex
on the parent element .menu-item-1
, but it doesn't seem to be working as expected. Any ideas why?
I am required to use li
elements for this task and any help in understanding why it's not working properly would be greatly appreciated.
Currently, the 6 sub menu items are stacked on top of each other, making it look like there are only 3 items visible at once.
To see the code in action, visit the following link: https://codepen.io/emilychews/pen/LwPvbq
li {list-style-type: none}
ul.nav-menu-items {
display: flex;
justify-content: flex-start;
}
.menu-item {
list-style-type: none;
position: relative;
padding: 2rem 1rem 2rem 1rem
}
.menu-item-1 {
display: flex;
}
/* SUB MENU */
.submenu {
position: absolute;
background: lightblue;
padding: 1rem;
top: 5rem;
visibility: hidden;
width: 22rem;
}
.submenu-item {
padding-bottom: .5rem;
}
.submenu-item:last-child {
padding-bottom: 0;
}
.menu-item:hover .submenu {
visibility: visible;
opacity: 1;
}
<ul class="nav-menu-items">
<li class="menu-item menu-item-1">MENU-ITEM
<ul class="submenu pratice-areas-submenu-1">
<li class="submenu-item submenu-item-1"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
<li class="submenu-item submenu-item-3"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
<li class="submenu-item submenu-item-5"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
</ul>
<ul class="submenu pratice-areas-submenu-2">
<li class="submenu-item submenu-item-1"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
<li class="submenu-item submenu-item-3"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
<li class="submenu-item submenu-item-5"><a href="./" class="navigation--link">SUB MENU ITEM</a></li>
</ul>
</li>
</ul>