Steps to create a div with a z-index of 1 that fills the entire height:

Looking at the image, I have a sidebar that opens over other elements (blue color) using z-index = 1. When the sidebar is open, I want to hide all other elements except for the sidebar. However, towards the end of the sidebar, I can still see other elements from the page such as Sheets A and Sheets B.

I have tried setting different values like 100vh, 500vh, 100%, auto but none seem to work. Is there a way to make the element with Z-index = 1 occupy the entire vertical screen?

https://i.stack.imgur.com/M2Uib.png

.navigationbar--open .navigationbar__body {
    max-height: auto;
    opacity: 1;
}

html

<div className="navigationbar--open">
    <div className="navigationbar__heading">

        <div className="foldersection">
            <img src={image} className="navbar__icon" />

        </div>
        <FaSortDown />
    </div>
    <div className="navigationbar__body">

          <li>Folder A</li>
          <li>Folder B</li>
          <li>Folder C</li>

        ))}
    </div>
</div>

Answer №1

To achieve the desired outcome, CSS properties such as overflow, display, height, and width can be utilized effectively. In this demonstration, I ensure that the navbar element spans the entire screen by setting its height to 100vh (representing 100% of the vertical viewport) and preventing vertical scrolling or display of other elements with the overflow-y property set to hidden. Toggling the button element triggers a change in the display property to flex for the nav element. See the example below.

$('.btn').click(function() {
    $('nav').toggleClass('open');
});
nav {
    height: 100vh;
    width: 100vw;
    background: pink;
    overflow-y: hidden;
    position: fixed;
    top: 0;
    left: 0;
    display: none;
    flex-direction: column;
}

nav.open {
    display: flex;
}

.btn {
    position: absolute;
    top: 25px;right: 25px;
    z-index: 2;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<div>some other page content above some other page content above some other page content above some other page content abovesome other page content above</div>
<button class='btn'>btn</button>
<nav>
  <span>some nav item 1</span>
  <span>some nav item 1</span>
  <span>some nav item 1</span>
</nav>
<div>some other page content above some other page content above some other page content above some other page content abovesome other page content below some other page content above some other page content above some other page content above some other page content abovesome other page content below some other page content above some o... 

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

What strategies can be implemented to minimize the impact of HTML code on just one specific div (or any other chosen element)?

<div> <b> some example </div> different content This will make the "different content" bold. Is there a way to restrict the impact of <b> only to the <div> element? I have tried looking for JavaScript solutions online but did ...

Issue with creating a new jstree node

I recently put together a basic jstree. When I click on a link, it triggers the createNode() function. This function utilizes the create feature from the API to generate a new node. It appears to be a common issue with jQuery that I am encountering. Any ...

The clash between CSS's 'snap-scroll' and jQuery's '.animate scrollLeft' functionality

My HTML and CSS slider utilizes the scroll-snap feature for manual scrolling along with jQuery buttons for automated scrolling. However, I have encountered an issue where using scroll-snap-type: x mandatory; causes severe lag in the jQuery scrollLeft anima ...

Using Javascript's document.write function to modify the content of a PHP page

Here is a Javascript function that capitalizes the first letter of a string: function capitalizeFL(string) { return string.charAt(0).toUpperCase() + string.slice(1); } In a file named statuswindow.php, there are PHP scripts that use this function to ...

Focusing solely on a particular category in EJS

I am struggling with this code snippet. HTML: <header<% if ( current.source === 'features' || current.path[0] === 'index' || current.source !== 'customers' ) { %> class="header-white"<% } %>> <div cl ...

How to Choose Between Landscape and Portrait Printing Modes in Firefox and Internet Explorer 8

Currently, I am using the latest version of FireFox and IE8. In order to change the printing orientation, I utilized the following code in my CSS file: @page { size: portrait; } You can find more information about the @page property here. Although it i ...

Creating a loading animation using HTML and CSS for textual content

I came across a website that had a unique text loading effect, but despite my efforts, I couldn't find what it's called. Effect: https://i.stack.imgur.com/NyaSN.png Is there any plugin or CSS file available for this effect, similar to Bootstra ...

When using JavaScript, links within the window.location are automatically altered

When using window.location (.assign, .replace, .href) to redirect to a product page on click, I encountered an issue where it automatically changes some of the href links. For example: instead of "previous href= 'commercial/fonts/fonts.min.css' ...

Adjusting the height of the navigation bar in BootStrap

I'm having trouble resizing the height of the navbar-default in this Bootstrap sample. It seems to be too big for my needs. Are there any Bootstrap classes I can use to adjust the height? For example: <form class="navbar-form navbar-left" role="s ...

Scrollmagic - Creating dynamic effects by animating body and div backgrounds using multiple tweens

I'm currently developing a website that utilizes scrollmagic to smoothly transition the color of the active div (each set to size of the screen) from black back to white as you scroll down. The issue I am facing is that the body background color does ...

What is the best way to showcase a variable from a switch statement on my ASP.NET web page?

Looking to format the month from a datetime object as text in this style: 01 Dec 2011 A switch statement was set up to determine the month and assign it to a variable for display on index.aspx. However, the code doesn't seem to be functioning as e ...

Insert a new store into an existing IndexedDB database that is already open

After opening and passing the onupgradeneeded event in IndexedDB, is there a way to create a new store? My attempted code: var store = db.createObjectStore('blah', {keyPath: "id", autoIncrement:true}); This resulted in the following error mess ...

JavaScript - Modify the proposed content prior to inserting it into the input field

In my current project, I have implemented a feature using jQuery UI - v1.11.4, where an HTML textbox utilizes a JavaScript autocomplete functionality. The suggested string for the textbox is created by concatenating several columns (patient_no, patient_nam ...

What is the best way to design a div that includes two separate columns for text and an image icon?

Check out this code: <?php foreach ($data as $vacancy) { ?> <div class="vacancy"> <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/vacancy_icon.jpg" /> <div class="name"> < ...

Specialized function to identify modifications in data attribute value

I have a container with a form inside, featuring a custom data attribute named data-av Here is how I am adding the container dynamically: > $("#desti_div").append("<div class='tmar"+count+"'><div > class='form-group col-md-6 ...

Tips for reducing the height of the footer without compromising the alignment of the text within

My attempt to reduce the height of my footer in CSS using padding, margin, and other methods was unsuccessful. All of these adjustments either pushed the footer completely out of the bottom or left the text uncentered. footer { background: #fce138; wid ...

How to Save Information to MySQL Database Using an HTML Form with Checkboxes

I recently set up an HTML form that includes checkboxes and successfully managed to store the values using an array in my database. After adding a name field to the form along with a corresponding column in my MySQL table, I hit a roadblock. The new name ...

Introducing Row Offset Enhancement

I am working on a code to create a custom "table" because I require some more intricate features that a regular table cannot provide. <div class="container"> <cfloop index="x" from="1" to="5"> ...

The upper section of the pop-up modal is not fully visible when the screen size is decreased

My modal is experiencing an issue where the top part gets cut off when the screen is reduced, disappearing under the bookmarks and address bar. I attempted a solution mentioned in this resource by setting the top and bottom to 0, but it did not resolve the ...

Is it possible to enable an email hyperlink to function on a computer?

I successfully created an email link that is functional on mobile devices by using 'href="mailto:[email protected]"'. When I click on the button from a mobile device, it prompts me to choose how I want the email delivered. However, when I tr ...