First of all, I’m pretty much a beginner at this.
Here is my HTML:
<nav id="site-navigation" class="main-navigation main-navigation--default">
<div class="container">
<a href="#" class="navigation-bar-toggle">
<i class="ion-navicon-round"></i>
<span class="mobile-nav-menu-label">Menu</span>
</a>
<div class="navigation-bar-wrapper">
<div class="primary nav-menu">
<ul id="menu-menu-1" class="primary nav-menu">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home current-menu-item page_item page-item-107 current_page_item menu-item-has-children menu-item-182"><a href="https://example.com">Homepage</a>
<ul class="sub-menu">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-820"><a href="https://example.com/service1">Service 1</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-823"><a href="https://example.com/service2">Service 2</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-818"><a href="https://example.com/service3">Service 3</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-821"><a href="https://example.com/service4">Service 4</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-822"><a href="https://example.com/service5">Service 5</a></li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-183"><a href="https://example.com/about">About</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-184"><a href="https://example.com/contact">Contact</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-185"><a href="https://example.com/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</nav>
And here is my css:
.main-navigation,
.tertiary-navigation {
background-color: #fff;
position: relative;
z-index: 50; }
.tertiary-navigation {
z-index: 1; }
.navigation-bar-toggle {
padding: 10px 0;
display: inline-block;
vertical-align: middle; }
.navigation-bar-toggle {
float: left; }
ul.nav-menu [class^="ion"]:before,
.nav-menu [class^="ion"]:before {
font-size: 20px;
vertical-align: middle;
margin-right: 7px;
margin-top: -5px; }
.main-navigation .mega-category-list-wrapper,
.primary-header .nav-menu.primary {
display: none;
vertical-align: middle; }
.nav-menu ul,
.nav-menu {
margin: 0;
padding: 0;
list-style: none; }
.navigation-bar-toggle {
vertical-align: middle;
font-size: 15px; }
.navigation-bar-toggle i {
margin-right: 5px;
vertical-align: middle; }
.navigation-bar-toggle i {
font-size: 25px; }
.site-header .nav-menu-container,
.site-header .menu {
display: inline-block; }
.navigation-bar-wrapper {
display: block;
position: absolute;
padding: 0;
top: 100%;
left: 10px;
right: 10px;
z-index: 99999;
border-radius: 4px;
box-shadow: rgba(0, 0, 0, 0.06) 0 0 0 3px;
background: #fff;
display: none; }
.site-header .navigation-bar-wrapper {
z-index: 110; }
.navigation-bar-wrapper.active {
display: block; }
.navigation-bar-wrapper:before,
.navigation-bar-wrapper:after {
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
content: ' ';
position: absolute;
top: -10px;
left: 14px;
z-index: 10; }
.navigation-bar-wrapper:before {
border-color: transparent transparent rgba(0, 0, 0, 0.06) transparent;
border-width: 0 11px 11px 11px;
top: -14px;
left: 13px;
z-index: 7; }
.nav-menu {
padding: 2em;
border-bottom: 1px solid #e9edf2; }
.nav-menu:last-child {
border-bottom: 0; }
ul.nav-menu li > a,
.nav-menu li > a {
padding: 6px 0;
font-size: 125%;
display: inline-block; }
.nav-menu ul ul {
padding-left: 1em;
border-left: 1px solid #e9edf2; }
.nav-menu ul .category-list {
top: auto;
left: 0;
padding: 0;
border: 0; }
.nav-menu.secondary .sub-menu.category-list {
left: 0; }
.nav-menu ul .category-list select,
.nav-menu ul .category-list .select {
width: 100%; }
.nav-menu ul ul a {
font-size: 105%; }
.nav-menu li#categories-mega-menu {
margin-top: 5px;
margin-bottom: 5px; }
@media (min-width: 992px) {
.navigation-bar-wrapper,
.main-navigation .mega-category-list-wrapper {
display: block; }
.primary-header .nav-menu.primary {
display: table-cell; }
.navigation-bar-toggle,
.navigation-bar-wrapper .primary,
.category-list .postform-wrapper,
.navigation-bar-wrapper:before,
.navigation-bar-wrapper:after {
display: none; }
.navigation-bar-wrapper {
position: inherit;
top: auto;
left: auto;
right: auto;
bottom: auto;
background: none;
box-shadow: none;
padding: 0; }
.nav-menu,
ul.nav-menu {
padding: 0;
border: 0; }
.nav-menu.secondary ul.sub-menu li.menu-item-has-children:before,
.nav-menu.secondary li.menu-item-has-children:after, .nav-menu.tertiary ul.sub-menu li.menu-item-has-children:before,
.nav-menu.tertiary li.menu-item-has-children:after,
ul.nav-menu.secondary ul.sub-menu li.menu-item-has-children:before,
ul.nav-menu.secondary li.menu-item-has-children:after,
ul.nav-menu.tertiary ul.sub-menu li.menu-item-has-children:before,
ul.nav-menu.tertiary li.menu-item-has-children:after {
display: none;
content: ''; }
.nav-menu.secondary ul.sub-menu li.menu-item-has-children:after,
.nav-menu.secondary li.menu-item-has-children:before, .nav-menu.tertiary ul.sub-menu li.menu-item-has-children:after,
.nav-menu.tertiary li.menu-item-has-children:before,
ul.nav-menu.secondary ul.sub-menu li.menu-item-has-children:after,
ul.nav-menu.secondary li.menu-item-has-children:before,
ul.nav-menu.tertiary ul.sub-menu li.menu-item-has-children:after,
ul.nav-menu.tertiary li.menu-item-has-children:before {
display: inline-block;
font-family: "Ionicons";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-rendering: auto;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 20px;
vertical-align: middle;
margin-right: 5px;
margin-top: -1px;
content: "f3d0"; }
.nav-menu.secondary ul.sub-menu li.menu-item-has-children:after, .nav-menu.tertiary ul.sub-menu li.menu-item-has-children:after,
ul.nav-menu.secondary ul.sub-menu li.menu-item-has-children:after,
ul.nav-menu.tertiary ul.sub-menu li.menu-item-has-children:after {
content: ""; }
.nav-menu.secondary ul.sub-menu, .nav-menu.tertiary ul.sub-menu,
ul.nav-menu.secondary ul.sub-menu,
ul.nav-menu.tertiary ul.sub-menu {
right: auto;
left: -16px; }
.nav-menu.secondary ul.sub-menu:before, .nav-menu.tertiary ul.sub-menu:before,
ul.nav-menu.secondary ul.sub-menu:before,
ul.nav-menu.tertiary ul.sub-menu:before {
right: auto;
left: 12px; }
.nav-menu.secondary ul.sub-menu:after, .nav-menu.tertiary ul.sub-menu:after,
ul.nav-menu.secondary ul.sub-menu:after,
ul.nav-menu.tertiary ul.sub-menu:after {
right: auto;
left: 13px; }
.nav-menu.secondary li:hover ul ul, .nav-menu.tertiary li:hover ul ul,
ul.nav-menu.secondary li:hover ul ul,
ul.nav-menu.tertiary li:hover ul ul {
right: auto;
left: 195px; }
.nav-menu.secondary li:hover ul ul:after, .nav-menu.secondary li:hover ul ul:before, .nav-menu.tertiary li:hover ul ul:after, .nav-menu.tertiary li:hover ul ul:before,
ul.nav-menu.secondary li:hover ul ul:after,
ul.nav-menu.secondary li:hover ul ul:before,
ul.nav-menu.tertiary li:hover ul ul:after,
ul.nav-menu.tertiary li:hover ul ul:before {
right: auto;
left: -10px;
top: 8px;
border-width: 10px 10px 10px 0;
border-color: transparent #fff transparent transparent; }
.nav-menu.secondary li:hover ul ul:before, .nav-menu.tertiary li:hover ul ul:before,
ul.nav-menu.secondary li:hover ul ul:before,
ul.nav-menu.tertiary li:hover ul ul:before {
border-width: 11px 11px 11px 0;
border-color: transparent rgba(0, 0, 0, 0.06) transparent transparent;
top: 7px;
right: auto;
left: -14px; }
.nav-menu li,
ul.nav-menu li {
display: inline-block;
margin-right: 25px;
position: relative; }
.nav-menu li a,
ul.nav-menu li a {
font-size: 100%;
padding: 18px 0;
display: inline-block; }
.nav-menu li a:hover,
ul.nav-menu li a:hover {
text-decoration: none; }
.nav-menu li:hover > ul,
.nav-menu li:hover > ul > ul,
ul.nav-menu li:hover > ul,
ul.nav-menu li:hover > ul > ul {
display: block;
z-index: 101; }
.nav-menu li:hover > ul li,
.nav-menu li:hover > ul > ul li,
ul.nav-menu li:hover > ul li,
ul.nav-menu li:hover > ul > ul li {
display: block;
margin-right: 0; }
.nav-menu li:hover ul ul,
ul.nav-menu li:hover ul ul {
top: 0;
margin-top: 0;
right: 195px;
left: auto;
border-radius: 6px; }
.nav-menu li:hover ul ul:after, .nav-menu li:hover ul ul:before,
ul.nav-menu li:hover ul ul:after,
ul.nav-menu li:hover ul ul:before {
right: -10px;
top: 6px;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent #fff; }
.nav-menu li:hover ul ul:before,
ul.nav-menu li:hover ul ul:before {
border-width: 11px 0 11px 11px;
border-color: transparent transparent transparent rgba(0, 0, 0, 0.06);
top: 5px;
right: -14px; }
.nav-menu li#categories-mega-menu,
ul.nav-menu li#categories-mega-menu {
margin-top: 0;
margin-bottom: 0;
position: inherit; }
.nav-menu li[class^=ion] > a,
ul.nav-menu li[class^=ion] > a {
margin-left: -22px;
padding-left: 22px; }
.nav-menu li[class^=ion]:before,
ul.nav-menu li[class^=ion]:before {
margin-top: -2px; }
.nav-menu li.menu-item-has-children:after,
ul.nav-menu li.menu-item-has-children:after {
display: inline-block;
font-family: "Ionicons";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-rendering: auto;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 20px;
vertical-align: middle;
margin-left: 5px;
margin-top: -1px;
content: "f3d0"; }
.nav-menu .sub-menu,
.nav-menu .children,
ul.nav-menu .sub-menu,
ul.nav-menu .children {
display: none;
position: absolute;
padding: 10px 0;
top: 95%;
right: -16px;
z-index: 99999;
border-radius: 4px;
width: 200px;
box-shadow: rgba(0, 0, 0, 0.06) 0 0 0 3px;
background: #fff;
border: 0;
transition: all 0.1s linear; }
.nav-menu .sub-menu ul,
.nav-menu .children ul,
ul.nav-menu .sub-menu ul,
ul.nav-menu .children ul {
left: 0;
right: auto; }
.nav-menu .sub-menu li:last-child,
.nav-menu .children li:last-child,
ul.nav-menu .sub-menu li:last-child,
ul.nav-menu .children li:last-child {
border-bottom: 0; }
.nav-menu .sub-menu li.menu-item-has-children:after,
.nav-menu .children li.menu-item-has-children:after,
ul.nav-menu .sub-menu li.menu-item-has-children:after,
ul.nav-menu .children li.menu-item-has-children:after {
display: none; }
.nav-menu .sub-menu a,
.nav-menu .children a,
ul.nav-menu .sub-menu a,
ul.nav-menu .children a {
margin: 0;
padding: 6px 22px;
display: inline-block; }
.nav-menu .sub-menu li[class^=ion],
.nav-menu .children li[class^=ion],
ul.nav-menu .sub-menu li[class^=ion],
ul.nav-menu .children li[class^=ion] {
padding-left: 22px; }
.nav-menu .sub-menu li[class^=ion] > a,
.nav-menu .children li[class^=ion] > a,
ul.nav-menu .sub-menu li[class^=ion] > a,
ul.nav-menu .children li[class^=ion] > a {
margin-left: 0;
padding-left: 0; }
.nav-menu .sub-menu:before, .nav-menu .sub-menu:after,
.nav-menu .children:before,
.nav-menu .children:after,
ul.nav-menu .sub-menu:before,
ul.nav-menu .sub-menu:after,
ul.nav-menu .children:before,
ul.nav-menu .children:after {
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
content: ' ';
position: absolute;
top: -10px;
right: 13px;
z-index: 10; }
.nav-menu .sub-menu:before,
.nav-menu .children:before,
ul.nav-menu .sub-menu:before,
ul.nav-menu .children:before {
border-color: transparent transparent rgba(0, 0, 0, 0.06) transparent;
border-width: 0 11px 11px 11px;
top: -14px;
right: 12px;
z-index: 7; }
.nav-menu .sub-menu.category-list,
.nav-menu .children.category-list,
ul.nav-menu .sub-menu.category-list,
ul.nav-menu .children.category-list {
left: 0;
right: 0;
width: 100%;
max-height: 500px;
overflow-y: auto;
position: absolute;
box-shadow: rgba(0, 0, 0, 0.1) 2px 1px 0;
background: #f0f3f6;
border-radius: 0;
padding: 30px 0;
z-index: 10; }
.nav-menu .sub-menu.category-list:before, .nav-menu .sub-menu.category-list:after,
.nav-menu .sub-menu.category-list .children:before,
.nav-menu .sub-menu.category-list .postform,
.nav-menu .sub-menu.category-list .select,
.nav-menu .children.category-list:before,
.nav-menu .children.category-list:after,
.nav-menu .children.category-list .children:before,
.nav-menu .children.category-list .postform,
.nav-menu .children.category-list .select,
ul.nav-menu .sub-menu.category-list:before,
ul.nav-menu .sub-menu.category-list:after,
ul.nav-menu .sub-menu.category-list .children:before,
ul.nav-menu .sub-menu.category-list .postform,
ul.nav-menu .sub-menu.category-list .select,
ul.nav-menu .children.category-list:before,
ul.nav-menu .children.category-list:after,
ul.nav-menu .children.category-list .children:before,
ul.nav-menu .children.category-list .postform,
ul.nav-menu .children.category-list .select {
display: none; }
.nav-menu .sub-menu.category-list a,
.nav-menu .children.category-list a,
ul.nav-menu .sub-menu.category-list a,
ul.nav-menu .children.category-list a {
padding: 12px 0;
display: block; }
.nav-menu .sub-menu.category-list .container,
.nav-menu .children.category-list .container,
ul.nav-menu .sub-menu.category-list .container,
ul.nav-menu .children.category-list .container {
position: relative; }
.nav-menu .sub-menu.category-list .container:before,
.nav-menu .children.category-list .container:before,
ul.nav-menu .sub-menu.category-list .container:before,
ul.nav-menu .children.category-list .container:before {
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 10px 0 10px;
border-color: #fff transparent transparent transparent;
content: ' ';
position: absolute;
top: -30px;
left: 28px;
z-index: 10; }
.nav-menu .sub-menu.category-list .category-count,
.nav-menu .children.category-list .category-count,
ul.nav-menu .sub-menu.category-list .category-count,
ul.nav-menu .children.category-list .category-count {
font-size: 11px;
border-radius: 2px;
margin-right: 8px;
padding: 4px;
display: inline-block;
min-width: 30px;
text-align: center; }
.nav-menu .sub-menu.category-list .mega-category-list-wrapper,
.nav-menu .children.category-list .mega-category-list-wrapper,
ul.nav-menu .sub-menu.category-list .mega-category-list-wrapper,
ul.nav-menu .children.category-list .mega-category-list-wrapper {
max-width: 75%; }
.nav-menu .sub-menu.category-list li,
.nav-menu .children.category-list li,
ul.nav-menu .sub-menu.category-list li,
ul.nav-menu .children.category-list li {
width: 23%;
float: left;
margin-right: 2%; }
.nav-menu.primary {
text-align: right;
padding-left: 4em; }
.nav-menu.primary ul ul {
text-align: left; }
.nav-menu .account-avatar > a {
padding: 8px 0; } }
@media (min-width: 992px) {
.main-navigation--transparent {
display: none; } }
.nav-menu.tertiary li.current-menu-item a:before,
.nav-menu.tertiary li.is-active a:before {
content: ' ';
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%); }
When I click on the Hamburger Icon or the word "Menu" nothing happens.
How can I open the menu on click? Can it be done with just css or with jQuery?
2
Answers
I don’t think there is any trigger to open the menu in your code?
I use
:target
to toggle menu:First of all, please rename your class as it is too long to read. And the second is I can’t view your HTML document so I will show you my code. And third, from my experience, You need JavaScript to toggle a menu. See down below.
HTML
My CSS
and lastly my JavaScript