I've been learning how to create a hamburger menu for mobile devices.
Within a navigation structure, I have three components: Logo, nav-items, and hamburger menu. Utilizing flexbox, I arranged them side by side and initially hid the hamburger menu on desktop with display: none.
Despite my attempts to experiment with position relative/absolute, I'm facing some challenges. Changing flex-direction from row to column hasn't solved the issue either.
Below is the code for the navbar:
<nav class="nav">
<div class="brand"><h4>The Brand</h4></div>
<div class="navigation">
<ul class="navigation__list">
<li class="navigation__item">
<a href="#">Home</a>
</li>
<li class="navigation__item">
<a href="#">About</a>
</li>
<li class="navigation__item">
<a href="#">Services</a>
</li>
<li class="navigation__item">
<a href="#">Gallery</a>
</li>
<li class="navigation__item">
<a href="#">Blog</a>
</li>
<li class="navigation__item">
<a href="#">Contact</a>
</li>
</ul>
</div>
<button class="hamburger">
<span class="hamburger__box">
<span class="hamburger__inner"></span>
</span>
</button>
</nav>
My goal is to have the hamburger menu appear on mobile devices. The nav items should slide off the screen and align vertically. When the hamburger is clicked, I want them to slide in from the right.
Check out the codepen for a working example: https://codepen.io/kowalik9412/pen/WNeMQrO