Challenges with Z-index and layering dynamics

I'm having trouble getting z-index to work. I've searched online but can't find a solution.

How can I make the .navigation class have a lower z-index than the .mobilenav and .mobilenavclosed classes so that they appear above everything else?

I've tried adjusting the position of the elements and changing the z-index, but nothing seems to be working. Any advice would be appreciated!

Here is my HTML:

<div class="navWrapper" ng-controller="NavController">
<section class="navigation">
    <div class="nav-container">
        <button ng-click="openHamburger()" class="hamburger"><span   class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span></button>
        <nav>
            <ul class="nav-list" ng-repeat="navitem in navitems">
                <li>
                    <a href="#!">{{navitem.title}}</a>
                </li>


            </ul>
        </nav>
    </div>
</section>

<div ng-class="{'mobilenav': isOpen, 'mobilenavclose': isClosed}">
    <button ng-click="closeHamburger()" type="button" class="btn btn-default">
        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
    </button>
    <div class="menuwrapper">
        <button class="optionwrapper" ng-repeat="navitem in navitems">
            <div class="navicon"></div>
            <p>{{navitem.title}}<p>
        </button>
    </div>
</div>

This is my CSS:

@keyframes active {
from {
    border-bottom: 0px solid #5aaafa;
}
to {
    border-bottom: 5px solid #5aaafa;
}
}

body,
html {
height: 100%;
margin: 0 auto;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue",    Helvetica, Arial, "Lucida Grande", sans-serif;
color: red;
}

.menuwrapper {
display: none;
}

button.btn.btn-default {
display: none;
}

.navWrapper {
height: 100vh;
width: 100vw;
}

.activeindicator {
width: 100%;
height: 10%;
background: #5aaafa;
}

.hamburger {
display: none;
    }

.close {
display: none !important;
}

  .navhidden {
display: none !important;
}

.navigation {
width: 100%;
height: 50px;
background: #333;
color: white;
position: relative;
z-index: 1;
}

.navigation a {
color: white;
text-decoration: none;
font-weight: 300;
}

   .navigation a:hover {
   color: #ffffff;
   text-decoration: none;
   border-bottom: 5px solid #5aaafa;
  }
  
<!-- More CSS code -->

Answer №1

To achieve a layered effect, the bottom layer must have a relative position, while .mobilenav and .mobilenavclosed should have an absolute positioning. This is the technique I use for layering elements.

.mobilenav.mobilenavclose {
    height: 100vh;
    background: #5aaafa;
    width: 0vw;
    margin: 0px;
    animation: closeHamburger;
    animation-duration: 0.7s;
    position: absolute;
    z-index: 10;
}

Furthermore, .navigation does not require a z-index since it is meant to be at the bottom of the stacking order.

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

href not functioning properly on subsequent clicks, whereas onclick remains active

I'm experiencing an issue with a button that opens a modal. When clicking the button, it's supposed to open a new page in the modal and also make an API call for processing before loading the new page. <a class="btn btn-primary" type='b ...

Navigating an indefinite amount of state variables in React.js: A comprehensive guide

Receiving data from the server with an unknown number of items in the API leads me to utilize the map method in HTML for rendering. Below is the return section: if (loading) { return ( <div> <div> <Header /> ...

Can someone provide a method to access the namespace of an Angular controller when utilizing the "Controller As" format?

Imagine you have an AngularJS ngController directive set up like this: <div ng-controller="SomeCtrl as herpderp">…</div> Is there a way to extract the namespace ("herpderp") from within the SomeCtrl controller itself? This could be useful f ...

What is the process for installing and utilizing the custom CSSLint rules that I have developed for the command line interface?

After investing a significant amount of time into following the instructions outlined here and here for creating custom CSS linting rules using CSSLint via the CLI, I have successfully generated and tested my own set of rules. However, I am now facing the ...

Pattern for validating 19-digit Visa and Discover cards using Regex technology

Presently, I have implemented the regex patterns below but unfortunately they do not cater to 19-digit cards for both Visa and Discover. Could you please provide assistance with this issue? visaCardPattern: /^4[0-9]{12}(?:[0-9]{3})?$/ discoverCardPatte ...

Troubleshooting height adjustment for header and footer in CSS with dynamic content not functioning properly on Safari for macOS and Safari for iOS (jsBin)

I recently came across a solution by @RokoC.Buljan, which works perfectly on Chrome and Firefox. However, I encountered an issue with Safari where the content section does not scroll properly and the footer sticks to the bottom of the content, making it di ...

Implementing a loading spinner while using AngularJS $http.get request with the help

I'm looking to display a spinner while making an $http.get request. Here's a snippet of my code : AngularJS section : var portalSDM = angular.module('portalSDM', ['ui.router', 'agGrid', 'angular.filter', ...

Encountered a problem while transitioning an asp.net 5 project to .net 6: "Issue with conflicting assets sharing the same target path."

After upgrading my ASP.NET 5 project to ASP.NET 6, I encountered an error upon building: https://i.sstatic.net/uyWfm.png The transition from ASP.NET 5 to ASP.NET 6 involved incorporating razor pages along with AngularJS typescript files in my project. ...

Issue encountered while attempting to deactivate certain foundation CSS and JavaScript files

I am attempting to deactivate certain CSS files in the foundation framework, as they are unnecessary for my project. After installing foundation via a gem, I followed Ryan Bates' recommendation to modify the foundation_and_overrides.scss file by repl ...

Step-by-step guide on utilizing jQuery to fade out all elements except the one that is selected

There are multiple li elements created in this way: echo '<ul>'; foreach ($test as $value){ echo '<li class="li_class">.$value['name'].</li>'; } echo '</ul>'; This code will generate the fol ...

Is there a way for me to determine if the HTML code is creating a new line?

Here is my code snippet: <div id="box"> <p> 123 </p> <p> abc </p> </div> <script> var html = document.getElementById("box").innerHTML; for (var i = 0, len = html.length; i & ...

Displaying content on a webpage using PHP, AJAX, and HTML

Looking to update my current form setup. I have a basic Form below: <form action="" method="POST"> <input type="button" value="Generate Numbers" onclick="on_callPhp1()"/> </form> Accompanied by this javascript code: <script type="te ...

Converting PDF files to JSON in ASP.NET and transferring them to AngularJS using Base64 does not result in identical files

After encoding a PDF file as Base64 and assigning it to a property of my model object in ASP.NET WEB API, the JSON response is received by my AngularJS client application. However, upon saving the file, I noticed that the file size increases by one and 1/3 ...

From gathering user input on an HTML form, processing it using PHP, storing the data in a MySQL database, retrieving it with PHP, converting it to JSON

Description of issue: I am attempting to retrieve a value from an HTML input using PHP and execute a query on a MySQL database: SELECT * FROM WHERE (value = ID in the HTML input). MY APPROACH: I have created an HTML input: <input id="akt_djubrenje" ...

Using AngularJS to establish a connection with a remote server

I am working with a secure Restful API (localhost:8180) that requires authentication. I am using Angular JS HTTP services to log in to the server and retrieve data from localhost:8180/api/version/?1 (just an example). Below is the code snippet: //Config ...

JavaScript - Uncaught TypeError: type[totypeIndex] is not defined

After following a tutorial and successfully completing the project, I encountered a JavaScript error saying "Uncaught TypeError: totype[totypeIndex] is undefined". When I tried to log the type of totype[totypeIndex], it initially showed as String, but late ...

Calculating the Quantity of Specific Nodes within a JSON Dataset using AngularJS

Here is a collection of JSON data: "MyMessages": [ { "Code" : "N101", "ID" : "History", "Indicator" : "Down", "PosChangeMessage" : "test test test test", "NegReasonMessage" : "test test ...

Minimize the vertical gap between menu items when they wrap onto a new line

When examining the screenshot of the website, you'll notice a considerable space between the first and second rows of menu items. I'm aiming to minimize this spacing as much as possible. The following CSS pertains to this issue: .gva-navigatio ...

Choose the descendant element of the element that has a specific attribute

One of the issues I am facing is related to a button with a span tag inside for the text. Occasionally, this button might be disabled, and my goal is to have it appear grey when in that state. However, I am encountering difficulties making this work proper ...

What is the best way to implement conditional styling in Vue.js?

Looking to incorporate a conditional style into my Component. Here is my component: <site-pricing color="primary" currency="$" price="25" to="/purchase" > <template v-slot:title>Complete</templat ...