Skip to content

Instantly share code, notes, and snippets.

@zaynali53
Last active May 3, 2021 16:32
Show Gist options
  • Select an option

  • Save zaynali53/57188eeb245e805b4ea61f73a92b1ed1 to your computer and use it in GitHub Desktop.

Select an option

Save zaynali53/57188eeb245e805b4ea61f73a92b1ed1 to your computer and use it in GitHub Desktop.
Wordpress Basic Nav Menu (Multi Level)
/* Reset list styles */
.nav-menu, .nav-menu ul {
padding: 0;
z-index: 99999;
list-style: none;
}
/* Used flex to remove list item gaps */
.nav-menu {
display: flex;
}
.nav-menu a {
display: block;
color: #2f3640;
padding: 8px 16px;
white-space: nowrap;
text-decoration: none;
}
.nav-menu li:hover > a {
background-color: #dcdde1;
}
.nav-menu li {
position: relative;
}
/* Positioned beneath the hovered list item */
.nav-menu .sub-menu {
position: absolute;
display: none;
left: 0;
min-width: 100%;
background-color: #f5f6fa;
}
/* Positioned right next to the hovered list item */
.nav-menu .sub-menu .sub-menu {
top: 0;
left: 100%;
}
.nav-menu li:hover > .sub-menu,
.nav-menu li li:hover > .sub-menu {
display: block;
}
.nav-menu .menu-item-has-children:after {
position: absolute;
top: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 100%;
font-size: 8px;
color: #2f3640;
content: '▶';
}
/* Parent list item spacing for the caret */
.nav-menu .menu-item-has-children > a {
padding: 8px 32px 8px 16px;
}
.nav-menu .menu-item-has-children:hover:after {
content: '◀';
}
/* Horizontal list item hover caret */
.nav-menu > .menu-item-has-children:after {
content: '▼';
}
.nav-menu > .menu-item-has-children:hover:after {
content: '▲';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment