Is there a way to position the nav menu outside of the navbar without it overlapping?

After spending 4 hours trying to solve this problem, I've hit a roadblock. I'm attempting to create a responsive menu where the dropdown appears below the navbar when the hamburger menu is clicked, instead of overlapping it like in the current snippet.

<body>
    <nav class="nav">
      <img src="./img/logo.png" class="nav__logo" alt=" logo." />
      <ul class="nav__menu">
        <li class="nav__item"><a href="#" class="nav__link">link1</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link2</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link3</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link4</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link5</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link6</a></li>
        <li class="nav__item"><a href="#" class="nav__link">link7</a></li>
      </ul>
      <div class="hamburger__menu">
        <span class="bar"></span>
        <span class="bar"></span>
        <span class="bar"></span>
      </div>
    </nav>

    <script src="script.js"></script>
  </body>

I've attempted using z-index to achieve this, but adding a negative z-index to the menu prevents me from clicking on the links.

Answer №1

Combining the styles of nav and ul as siblings is crucial for achieving successful implementation. Additionally, attempting to apply z-index to a statically positioned element will not yield the desired effect.

Answer №2

Update the z-index property to -1

@media (max-width: 768px) {
  ...
  
  .nav__menu {
    ...
    z-index: -1;
  }
  
  ...
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Elevating the Material Design Lite Progress bar using ReactJS

I currently have MDL running with React and it appears to be functioning properly. The Progress Bar is displaying on the page as expected, loading with the specified progress on page load when a number is entered directly: document.querySelector('#qu ...

Tips for redirecting once a JavaScript timer has run out?

Looking to update the code once the timer (See code) has run out. Currently, I am working on an exciting auction project for a friend and when the timer expires, I want to change the page so that no more bids can be placed. All bids are time-sensitive, so ...

Steps to perform a double click on a word within a webpage using JavaScript in the browser's console

HTML: <iframe ..... <p class="textClass"> Some Text............. <span id="unique-id"> Double-Click Me</span> </p> </iframe> Requirement: I am seeking a solution to trigger a double-click programmatical ...

AWS Lambda - Nodejs: Memory allocation failed - JavaScript heap exhausted

I've implemented Lambda (nodeJS) to interact with noSQL data (DynamoDB). For instance, let's consider a "student" table in DynamoDB and an API that retrieves a list of students based on a specific class (class_id). This process involves using th ...

The function of the Angular ng-include form action for posting a URL appears to be malfunctioning

When a form post is included in a parent HTML using ng-include, it does not trigger the submission action. <div ng-include src="'form.html'"></div> The code in the form.html file is as follows: <form action="next/login" method = ...

Utilizing jQuery for seamless transitions between multiple background images

Looking to create a dynamic page using jQuery that alternates between different large background images for a fading effect. How can I achieve this? ...

Defining the dimensions of a Material Dialog box in Angular: A step-by-step guide

Thank you for taking the time to read this. I'm currently trying to create a dialog box with a specific size of 90% in width, but I'm facing some challenges in achieving this. Can anyone guide me in the right direction or just provide me with th ...

Ways to adjust the location of the scrollbar using CSS

Can the position of the scroll bar be modified using CSS to switch it from left to right or from bottom to top? ...

What is the best way to evenly distribute 4 images within a div?

How can I evenly space 4 social media buttons inside a div using CSS? CSS .socialbuttonstop { height: 150px; width: 35px; margin-left: 915px; position: absolute; } HTML <div class="header"> <div class="headercontent"> ...

What is the best way to prioritize .py-md-6 over .p-3 in Bootstrap 4?

I have set the padding for the class .py-md-6 as follows: .py-md-6 { padding-top: 6rem !important; padding-bottom: 6rem !important; } Despite this, there seems to be a conflict with the .p-3 class in my HAML element: #id.p-3.py-md-6 It appears th ...

Retrieve the value of an object without relying on hardcoded index values in TypeScript

I am working with an object structure retrieved from an API response. I need to extract various attributes from the data, which is nested within another object. Can someone assist me in achieving this in a cleaner way without relying on hardcoded indices? ...

Please guide me on using jQuery to identify and color a specific word within a text

Within the .content section, I am analyzing multiple HTML paragraphs of text. If any paragraph includes the word "Hello" in any case variation, I will only highlight that specific word in blue. Similarly, if a paragraph contains the word "Goodbye," it wi ...

"Upon requesting dialogues, the outcome appears to be ind

I have been experimenting with the dialogs npm package in my electron app to handle prompts. I created a simple prompt replacement function like so: function customPrompt(text){ let result dialogs.prompt(text , value => { result = value ...

Ensuring the accurate promise is delivered in Angular

I'm struggling to correctly return the promise for a service in Angular. Here is the function causing me trouble: postToSP.post($scope.sharePointURL, data).then(function() { $scope.gettingData = false; $scope.yammerListName = ...

What is the best way to add a stylish border to an iframe?

My attempt to add a border to content on my WordPress site has been unsuccessful. Since I don't know how to add a CSS file, I've been trying to achieve this using what I believe to be HTML. My coding skills are limited to what I learned in high s ...

Developing dynamic progress indicators in Django - A guide

I'm in the process of figuring out how to create a real-time progress bar for updating. The idea is that the server will update the user periodically on the current progress. Fortunately, I am familiar with making an Ajax call using Django and jQuery ...

Leveraging multiple routes for a single component in Angular 6

Creating a component named Dashboard for admin requires passing the username in the route to find user information. This is the routing setup: {path:'dashboard/:username',component:DashboardComponent,children:[ {path:'role',component: ...

Using Regular Expressions in Express routing

Does anyone have experience serving a file with a dynamic hash in its name on a specific route? The file is named like workbox-someHash.js and the hash changes every time the app is deployed. I attempted to serve it using the following code snippets: &qu ...

Unable to make jQuery animate top function work

I have three rectangles set up like this. I've managed to make them disappear when clicking the close button on the right side of each rectangle, but I'm struggling with getting the remaining rectangles to move upward to fill the empty space. Her ...

When the direction is set to rtl, special characters that are supposed to be at the

When using the direction property for a label with windows style directory paths containing backslashes, I encountered an issue. The purpose of using direction:rtl; was to display the end part (file names) of the path. However, I found that I am getting th ...