Remove the border when the menu is clicked on and add an overlay

Hey there, I'm Daniel and currently working on my portfolio website. My main goal is to implement an overlay effect when the hamburger menu is clicked on mobile devices. This overlay will darken the background to highlight the menu options. The overlay should disappear when clicking on the menu again, selecting a menu item, or tapping on the overlay itself.

Additionally, I've encountered a strange border-line issue that appears when opening the hamburger menu on mobile. I'm unsure how to remove it.

If you'd like to take a look at my website progress so far, here's the link:

(Please note that the latest version isn't live yet)

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta charset="UTF-8">
  <meta name="author" content="Daniel Gotz">
  <title>Daniel Gotz | Porfolio </title>
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/styles.css" rel="stylesheet">
  <link href="css/scrolling-nav.css" rel="stylesheet">
  <link href="dist/hamburgers.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Exo+2:600,900|Roboto" rel="stylesheet">
 </head>

<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">

  <!-- Navigation -->   
  <section id="intro" class="intro-section">
        <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header page-scroll">
          <button class="hamburger hamburger--spin navbar-toggle visible-xs" type="button" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class=" hamburger-box">
    <span class=" hamburger-inner"></span> </span>
          </button>
        </div>
        <div class="collapse navbar-collapse navbar-ex1-collapse">
          <ul class="nav navbar-nav right">
            <li class="hidden">
              <a class="page-scroll" href="#page-top"></a>
            </li>
            <li> <a class="page-scroll" href="#intro">Intro</a> </li>
            <li> <a class="page-scroll" href="#mijnwerk">Mijn werk</a> </li>
            <li> <a class="page-scroll" href="#overdaniel">Over Daniel</a> </li>
            <li> <a class="page-scroll" href="#contact">Contact</a> </li>
          </ul>
      </div>
    </nav>

    <div class="overlay" id="overlay"></div>

       <div class="title">
      <h1> Every mountain top is within reach if you just keep climbing</h1> </div>

      <div class="berg">
    <img src="berg.svg">

      </div>

  </section>
  <section id="mijnwerk" class="about-section"> </section>
  <section id="overdaniel" class="services-section"> </section>
  <section id="contact" class="contact-section"> </section>
  <!-- jQuery -->
  <script src="js/jquery.js"></script>
  <!-- Bootstrap Core JavaScript -->
  <script src="js/bootstrap.min.js"></script>
  <!-- Scrolling Nav JavaScript -->
  <script src="js/jquery.easing.min.js"></script>
  <script src="js/scrolling-nav.js"></script>
  <script src="js/hamburgers.js"></script>
</body>

</html>

CSS:

.overflow {
  overflow-x: hidden;
  position: relative;
}

.home {
  height: 100vh;
  width: 100vw;
  background-color: #2ecc71;
}

.mijnwerk {
  height: 100vh;
  width: 100vw;
  background-color: #27ae60;
}

.navbar-default {
  background: none;
  border-color: transparent;
    z-index: 3;  
}

.right {
  float: right;
  text-align: right;
}

// More CSS properties...

JS:

// Look for .hamburger
  var hamburger = document.querySelector(".hamburger");
  // On click
  hamburger.addEventListener("click", function() {

    // Toggle class "is-active"
    hamburger.classList.toggle("is-active");
    // Do something else, like open/close menu
  });

I would greatly appreciate any assistance with these issues! Thank you in advance!

Answer №1

To customize the menu appearance, simply add a background color to it and remove the close button as well as the border.

 .navbar-collapse navbar-ex1-collapse collapse in {
        background: rgba(27, 27, 62, 0.5);
    }

 .navbar-default {
    background: none;
    border: none;
    z-index: 3;
    }

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

Guide to integrating various HTML files into a single HTML file with the help of Vue.js

Although I am familiar with using require_once() in PHP, unfortunately, I am unable to use PHP in my current project. I attempted to use w3-include from W3Schools as an alternative, but encountered issues with loading my scripts. Even utilizing JavaScript ...

Unable to attach an event listener to an element fetched from an API

I'm currently in the process of developing a trivia web application using an API, and my goal is to incorporate an event listener onto the button which corresponds to the correct answer. This way, when users click on it, a message will appear confirmi ...

Can an image be inserted at the top left corner of a div's border by cropping the border?

I'm struggling to replicate a specific image design where the border cuts off within a certain distance. Despite my best efforts, I can't seem to achieve the desired cut-off effect for the border. Below is the HTML code for the quote and image: ...

Tips for shutting down the pop-up notification with Playwright?

Recently, I delved into the Playwright API and started working on an automation test. The test revolves around logging into a bank account and performing a specific action. However, I encountered a roadblock when a message box popped up on the bank's ...

Aligning buttons using JavaScript

I'm currently working on a layout with a horizontal div where buttons (referred to as letters in the code) are being created. However, I've encountered an issue where the buttons are aligning to the left side of the div and I'm unable to cen ...

Exploring the process of creating dot-based games on a canvas surface

I created a game called Dots on Canvas. You can learn more about the game by visiting this wiki link: https://en.wikipedia.org/wiki/Dots_(game). I am encountering an issue with drawing a polygon in the game. Can someone provide guidance on how to implement ...

Real-time database on Firebase website encountering an error despite the correct path being specified

excerpt from the import section: ... import { ref, getDownloadURL, deleteObject } from "firebase/storage"; import { child, get } from "firebase/database"; ... This is the function code snippet: function getDirectLink() { console.lo ...

Issue: NS_ERROR_FAILURE encountered in Firefox when using getBBox()

Is there a way to use the method getBBox() in SVG to retrieve the width and height of an element? I have included my code below, which works in Chrome but not in Firefox. If anyone has a solution to this issue, please let me know. try { console.log( ...

You must add the module-alias/register to each file in order to use path aliases in

I am currently utilizing typescript v3.6.4 and have the following snippet in my tsconfig.json: "compilerOptions": { "moduleResolution": "node", "baseUrl": "./src", "paths": { "@config/*": ["config/*"], "@config": ["config"], ...

Display a modal using jQuery, PHP, and Ajax to verify if a user is

Using a combination of jQuery, PHP, and Ajax, I am able to check if a user is logged in or not. JavaScript: jQuery(document).ready(function() { setInterval(function() { jQuery.ajax({ url: 'chkLoggedin.php', type: 'POST', ...

A unique way to present data: An HTML table featuring four fixed columns with horizontal scrolling

I've been having difficulty creating a table with fixed first four columns while allowing the rest to scroll horizontally. I came across this example first column fixed Although the example has the first column fixed, I'm struggling to extend it ...

Add a style to every div except for the final one

I've attempted to add a unique style to all divs with the same class within a parent div, except for the last one. Strangely, my code doesn't seem to work as expected for this particular case. Can anyone spot what I might be overlooking? Right no ...

Firefox not responding to mouse movements

I am experimenting with creating an "animation" using JavaScript's "mousemove" Check it out here This is the code I am currently using $("body").mousemove(function(e){ var wWidth = $("body").width()/2 var wHeight = $("body").height()/2 var posX; v ...

The Django CSRFToken middleware causes the URL to display after sending a "PUT" request to the server, presenting an issue with AJAX

In my current project using Django Python/Javascript, I'm facing an issue with the PUT request. The request is successfully sent to the server by the client, but after that, the page automatically refreshes, exposing the csrf token middleware in the U ...

Popstate functionality not functioning correctly, requiring multiple consecutive clicks

I am currently delving into the world of History Web API, but I've encountered my first challenge. While I have successfully implemented history.pushState, I am facing difficulties with popstate. It works perfectly the first time after an AJAX page l ...

Tips for toggling password visibility by clicking outside a password field

As I work on creating a password field that allows users to toggle the visibility of their password by clicking an eye icon, I am facing a challenge. I want the password to be hidden automatically when the user clicks outside the field, which requires a co ...

Why are Ajax calls returning 404 in Google Cloud Platform but working perfectly on local servers?

I recently came across a fantastic repository that offers a Java REPL directly in the browser. I decided to fork it and deploy it as a Google Cloud app to enhance its security with HTTPS. Everything seems to be working smoothly, except for one issue: Unf ...

Error: Jasmine cannot access a property of undefined value

Just getting started with js and jasmine Attempting to create a jasmine test case for my method. Encountering an error: TypeError: Cannot read property '0' of undefined. Tried different ways of passing arrays into my method sports but still facin ...

A guide to automatically playing audio on a webpage using HTML and JavaScript

I'm currently in the process of developing a quiz application, and my goal is to have a sound play when a user enters the webpage to initiate the quiz. Initially, I attempted to use JavaScript to trigger the sound on page load, but unfortunately, the ...

Navigating an Array and Dividing all of its Elements by 100

Hi there, I'm new to JavaScript and working on my first question. I have an array that I want to loop through and divide each value by 100, then print the output to the console. Here's what I've got so far: var example =[5, 10, 15, 20] for ...