Concealing all page content, the drop-down navigation menu hides everything

I recently designed a DropDown navigation menu using CSS. However, I noticed that when I click on it, the page contents disappear entirely. I would like to modify this behavior so that instead of hiding the content, the dropdown menu either pushes the page content down or appears in front of the content.

<script type="text/javascript>
        $(".menu-toggle-btn").click(function () {
            $(this).toggleClass("fa-times");
            $(".navigation-menu").toggleClass("active");
        });
    </script>
body{
    /*font-family:Calibri !important;*/
    font-family:ProximaNova,Arial,Sans-serif;
    margin: 0 2px;
    padding: 0;
    text-decoration: none;
    font-size:12px;
    /*max-width: 100%;*/
    overflow-x: hidden;
}
header{
  height: 45px;
  background: #008269;
  margin-bottom:2px;
}

.inner-width{
  max-width: 100%;
  /*padding: 0 10px;*/
  margin: auto;
}

.navigation-menu{
  float: left;
  display: flex;
  align-items: center;
  min-height: 45px;
}

.navigation-menu a{
  /*margin-left: 10px;*/
  color: #fff;
  text-transform: uppercase;
  font-size: 14px;
  padding: 1% 10%;
  border-radius: 4px;
  transition: .3s linear;
  font-weight:700;
  text-decoration: none;
}

.navigation-menu a:hover{
  background: #fff;
  color: #2f3640;
  transform: scale(1.1);
  text-decoration: none;
}

.navigation-menu i{
  margin-right: 8px;
  font-size: 16px;
}

.menu-toggle-btn{
  float: right;
  height: 20px;
  line-height: 20px !important;
  color: #fff;
  font-size: 26px;
  display: none !important;
  cursor: pointer;
}

@media screen and (max-width:1500px) {
  .menu-toggle-btn{
    display: block !important;
    margin-top:13px;
    margin-right:13px;
  }

  .navigation-menu{
    position:center;
    width: 100%;
    height:100%;
    /*max-width: 100%;*/
    background:#008269;
    top: 45px;
    right: 0;
    display: none;
    /*padding: 20px 40px;*/
    box-sizing: border-box;
  }

  .navigation-menu::before{
    content: "";
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #172b4d;
    position: absolute;
    top: -10px;
    right: 10px;
  }

  .navigation-menu a{
    display: block;
    margin: 10px 0;
  }

  .navigation-menu.active{
    display: block;
  }

}
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
      <meta charset="UTF-8>
      <meta name="viewport" content="width=device-width, initial-scale=1.0>
      <meta http-equiv="X-UA-Compatible" content="ie=edge>
      <title>Responsive Drop-down Navigation</title>
      <link href="css/MasterPage-CSS.css" rel="stylesheet" />

      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css>
      <script src="http://code.jquery.com/jquery-3.3.1.js></script>

      <link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600" rel="stylesheet>
    
    <asp:ContentPlaceHolder id="head" runat="server>
    </asp:ContentPlaceHolder> 
</head>
<body>    

   <form id="form2" runat="server> 
    <header>
          <div class="inner-width">
            <i class="menu-toggle-btn fas fa-bars"></i>
            <nav class="navigation-menu">
                 
                <a href="#">Products</a> 
                <a href="#">Customers</a>
                <a href="#">Sales</a>
                <a href="#">Installments</a>
                <a href="#">Financial</a>
                <a href="#">Stock</a>
                <a href="#">payroll</a>
                <a href="#">Expensis</a>

            </nav>
          </div>
        </header>
       
       <asp:ContentPlaceHolder id="contentBody" runat="server>
           <div style="overflow-x:auto;"></div>        
       </asp:ContentPlaceHolder>
   </form>
     
    <script type="text/javascript>
        $(".menu-toggle-btn").click(function () {
            $(this).toggleClass("fa-times");
            $(".navigation-menu").toggleClass("active");
        });
    </script>
</body>
</html>

Answer №1

I made a modification by including float: left; in the wrapping content div element

$(".menu-toggle-btn").click(function () {
    $(this).toggleClass("fa-times");
    $(".navigation-menu").toggleClass("active");
});
body {
    /*font-family:Calibri !important;*/
    font-family: ProximaNova, Arial, Sans-serif;
    margin: 0 2px;
    padding: 0;
    text-decoration: none;
    font-size: 12px;
    /*max-width: 100%;*/
    overflow-x: hidden;
}

header {
    height: 45px;
    background: #008269;
    margin-bottom: 2px;
}

.inner-width {
    max-width: 100%;
    /*padding: 0 10px;*/
    margin: auto;
}

.navigation-menu {
    float: left;
    display: flex;
    align-items: center;
    min-height: 45px;
}

.navigation-menu a {
    /*margin-left: 10px;*/
    color: #fff;
    text-transform: uppercase;
    font-size: 14px;
    padding: 1% 10%;
    border-radius: 4px;
    transition: .3s linear;
    font-weight: 700;
    text-decoration: none;
}

.navigation-menu a:hover {
    background: #fff;
    color: #2f3640;
    transform: scale(1.1);
    text-decoration: none;
}

.navigation-menu i {
    margin-right: 8px;
    font-size: 16px;
}

.menu-toggle-btn {
    float: right;
    height: 20px;
    line-height: 20px !important;
    color: #fff;
    font-size: 26px;
    display: none !important;
    cursor: pointer;
}

@media screen and (max-width:1500px) {
    .menu-toggle-btn {
        display: block !important;
        margin-top: 13px;
        margin-right: 13px;
    }

    .navigation-menu {
        position: center;
        width: 100%;
        height: 100%;
        /*max-width: 100%;*/
        background: #008269;
        top: 45px;
        right: 0;
        display: none;
        /*padding: 20px 40px;*/
        box-sizing: border-box;
    }

    .navigation-menu::before {
        content: "";
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-bottom: 10px solid #172b4d;
        position: absolute;
        top: -10px;
        right: 10px;
    }

    .navigation-menu a {
        display: block;
        margin: 10px 0;
    }

    .navigation-menu.active {
        display: block;
    }

}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css">
<script src="http://code.jquery.com/jquery-3.3.1.js"></script>

<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600" rel="stylesheet">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<form id="form2" runat="server">
    <header>
        <div class="inner-width">
            <i class="menu-toggle-btn fas fa-bars"></i>
            <nav class="navigation-menu">

                <a href="#"">Products</a> 
            <a href=" #"">Customers</a>
                <a href="#"">Sales</a>
            <a href=" #"">Installments</a>
                <a href="#"">Financial</a>
            <a href=" #"">Stock</a>
                <a href="#"">payroll</a>
            <a href=" #">Expensis</a>

            </nav>
        </div>
    </header>

    <asp:ContentPlaceHolder id="contentBody" runat="server">
        <div style="overflow-x:auto; float: left;">
        Lorem ipsum dolor, sit amet consectetur adipisicing elit. Autem totam delectus aspernatur veritatis deleniti repellat dignissimos recusandae alias odio necessitatibus cupiditate tempora, soluta voluptatum fuga non possimus officiis maiores culpa?
        <br>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Hic voluptas repellat deleniti laudantium rem nobis magni labore. Libero dolore fuga facere, beatae commodi voluptate assumenda repellendus, aperiam magnam voluptates consectetur. Lorem ipsum dolor sit amet consectetur adipisicing elit. Nihil voluptate blanditiis illo corrupti sunt pariatur soluta, laborum voluptates veniam facilis. Neque possimus natus assumenda enim magnam reprehenderit quas omnis voluptas?
        </div>
    </asp:ContentPlaceHolder>
</form>

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

Error message: An error occurred while executing the AJAX PHP code due to a TypeError, specifically stating that the property 'status' cannot be

For some reason, I keep receiving an undefined return for my response. The event handler in index.php triggers the following code: $.post("getData.php", onNewPost()); function onNewPost (response){ if (response.status == "OK") { console.log(resp ...

"Exploring the Power of Logarithmic Slider with Vue and Quasar

I'm currently working on a project utilizing Vue 2 and Quasar 1, where I am attempting to develop a logarithmic slider. Initially, I managed to create a basic example using a native input slider in this code pen: https://codepen.io/tonycarpenter/pen/Z ...

Cross-origin resource sharing (CORS) challenge encountered between an Express REST API server and an AngularJS application when running on separate ports

Our application utilizes a decoupled MEAN stack architecture. I am currently facing an issue when attempting to send a request from my Angular frontend to our backend, which is expected to return JSON data. However, each time I send a request from the fron ...

Issue with AngularJS controller method not functioning properly when assigned to a Div

I am facing an issue with a login form and its controller. The login function is not triggering upon submitting the form for some reason. Here is the code snippet for the form within the larger view file: <div class="login-wrap" ng-controller="LoginCt ...

Eliminated the right margin for desktop display

I'm looking to have a menu on the right side of my page. It looks good on mobile view with the menu aligned to the left and white space on the right. However, on desktop view, I want the menu to be aligned to the right with white space on the left. Ho ...

Creating tick lines around a solid gauge in Highcharts is a simple process that can enhance the

I am currently working with Highcharts and have a lot of dependencies on it, so I cannot use other plugins. $(function () { var gaugeOptions = { 'chart': { 'type': 'solidgauge' }, &a ...

Achieving a seamless scrolling effect using CSS

I recently completed the design of a basic website that includes both mobile and desktop versions. However, I am looking to incorporate some animation into the site to enhance its appearance. One specific feature is a "go up" link at the bottom of the mob ...

Trouble with displaying vertical scroll bar in React app when height is set to 100%

I am developing a React application where I need the content to always occupy at least 100% of the height to style the background accordingly. I have attempted to achieve this by setting the CSS height to 100% at the top level, which works fine. However, t ...

Extracting a portion of text from a column in an SQL database and loading it into a ListBox

Need assistance with the following : Currently using SQL database server 2008, where there is a table with columns displayed in the attached image. I am looking to retrieve the ToolTip column contents, extract the string after Controls:, and then separat ...

What is the best way to format the incoming data to display as HTML code?

My textarea has a v-model called content where input text is assigned to content.description. Now, I need to transfer this information to another element, specifically a div. The challenge lies in the fact that if my textarea includes HTML code, I want it ...

Show a list of checkbox options excluding the item that was chosen in the dropdown menu

I have a dropdown list of items and a popup (using colorbox for opening popup) with a list of checkboxes. The popup appears when '+Add/Edit' is clicked. Both the dropdown items and the checkboxes are generated dynamically in PHP from a complaint. ...

What is preventing NgClass from applying the CSS styles?

I'm currently facing an issue in Angular2 where I am trying to apply different styles using ngClass within an 'NgFor' loop, but for some reason, it's not working as expected. Apologies for any language errors. <div class='line ...

Charts.js fails to refresh data following an AJAX call

Having recently delved into the world of js and jquery, I managed to successfully display a chart using Flask and an Ajax request. However, I've hit a roadblock when it comes to refreshing the charts data. If I create a new chart each time as demonstr ...

Notify the ajax success if the returned data is null

Is there a way to display an alert message in the AJAX return request if no data is present? I have attempted this in the AJAX success function, but it seems to not be working! This is my current script: <script> $(document).ready(function () ...

Guide to arranging components in two columns using VueJS Vuetify Grid

My goal is to align two components in order to display data on two columns. I followed the official Vuetify Grid tutorial, but encountered some issues with fixed row components. Despite trying to change from row to column, it still doesn't work as exp ...

The cookie is not being sent by $http in request

Our current project involves developing a RESTful Webservice using AngularJS and Java Servlets. Upon user login, our backend sends a "Set-Cookie" header to the frontend. The cookie is accessed in Angular through $cookies (ngCookie module) and then set. On ...

Using Javascript to extract and organize JSON arrays from various sets of checkboxes

Is there a way to automatically create an array of multiple groups of arrays like this: arr = {arr1:{index:value, index2:value2}, arr2:{index,value, index2:value2}}; The order is based on groups of checkboxes in HTML (see example below): <div class=& ...

Encountered an error when attempting to load resource: net::ERR_CERT_AUTHORITY_INVALID following deployment on Vercel

I recently deployed a chatUI-app on Vercel that fetches chats from an API located at "http://3.111.128.67/assignment/chat?page=0" While the app worked perfectly in development, I encountered an issue after deploying it on Vercel where it ...

Adding JSON to the data attribute within a set of DOM elements

I am in the process of developing a website dedicated to recipes, where I am using a Mustache.js template to load recipe information from a JSON file. The structure of my JSON file is as follows: { "recipes":[ {"name": "A", preparationTime: "40min", "serv ...

Renewing Masonry and JQuery

Currently implementing Masonry from into a project aimed at creating a timeline effect for user interaction. The goal is to automatically refresh the page at intervals (every 10 seconds during testing), but encountered an issue. Upon initial load, the ge ...