"Create a responsive mobile navigation bar that stretches to 100% of the window height,

I've encountered an issue with the mobile version of my website. When users scroll to view content, clicking on an icon triggers a slide-in navigation bar from the left side and sets the body to have overflow: hidden;, effectively preventing further scrolling. Is there a way to make the navigation bar 100% height of the window instead of the entire document, allowing users to continue scrolling inside the navigation bar? Currently, the sliding animation and height adjustment are controlled by JavaScript, but I'm interested in finding a CSS solution for this problem. Can anyone provide guidance?

// CSS
#mobile_nav {
    width: 300px;
    position: fixed;
    top: 0;
    left: -300px;
    z-index: 10000;
    overflow: auto;
}

// JS
jQuery("#mobile_button").on("click", function() {
    jQuery("#mobile_nav")
        .css({ height: jQuery(window).height() });
        .stop(true)
        .animate({ left: 0 })
    ;
    jQuery("body").css({ overflow: "hidden" });
});

Answer №1

To achieve this effect, consider using Viewport units in your CSS code:

    height: 100vh;

If you're unsure about browser compatibility for this property, you can review it here.

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

Applying CSS transition delays to multiple images

I'm having trouble implementing a transition delay in my CSS. I've tried adding it in various places but it doesn't seem to be working as expected. This is my CSS: .imageBox { position: relative; float: left; transition ...

Leveraging Parameters from URL in Javascript

I'm facing an issue with my area shape, the href="/kosmetikstudios/deutschland/Bayern" tag seems to be causing a problem. I want to utilize the parameter "Bayern" (which is the last parameter in the URL). I need this to be dynamic. Below is my JavaS ...

Is there a way to pause the slideshow? Are there any ways I can enhance the code to make it more efficient?

Currently, I am testing a slideshow that automatically transitions every 1 second. I have set it up to pause when it reaches the first image. However, when it stops on the initial image and I click the next button, nothing happens. If I try to interact wit ...

What is the best way to combine two .csv files using JavaScript?

My situation involves having a pair of .csv files that resemble the following example: date,type,brand,model,price 2014-11-27, electric, tesla, model s , 100000 2014-11-27, diesel, bmw, m3, 90000 2014-12-13, hybrid, toyota, yaris , 20000 How do I go ...

Implement a vertical scrolling animation in datatables

I am trying to utilize datatables to display all data. My goal is to have the data automatically scroll row by row every 3 seconds. This is my code, and you can also check it out on jsfiddle The intention is to showcase this data on a large screen. < ...

What causes my field-set containers to overflow on mobile devices but not on larger screens?

I'm currently in the process of developing a mobile-first responsive website with forms. Here is the desired mockup I need to replicate after the 769px breakpoint: https://ibb.co/LQ0Gwt7. On the other hand, here is how it should look for 769px and bel ...

Issue with printing JavaScript value using Selenium_ASSUME_WE_NOT have any changes in the content

I'm currently running tests with Selenium and Java. I've experienced success in printing the pages' HTML from JavaScript by using an alert: js.executeScript("alert($('html').html());"); However, when trying to use return, nothing ...

Tips for seamlessly integrating XHP and ReactJS for a component's implementation

Imagine this scenario: a blog with a posts feed. Upon loading the page, three <PostCard>s are already loaded from the server-side. As the user scrolls down or clicks a Load more button, new post cards should be dynamically added to the page. We have ...

Passing props through Link in React can be a tricky process, especially when encountering issues with undefined props like this

My latest project involves creating a recipe research tool in react. The homepage features buttons that allow me to search for recipes and view them based on the data I gather. However, when I try to access the state values using 'console.log(this.pro ...

Executing Code in VueJS after an Event has been Successfully Dispatched

I am currently facing an issue where the form in the child component is being cleared before the event containing the entered form data is successfully passed to the parent component. As a result, the event passes empty values to the parent. I have tried u ...

URL not passing on variable

Here is the code I have for a basic 'change email' script. I'm currently struggling to get it working and can't figure out what's wrong. <?php if (isset($_GET['u'])) { $u = $_GET['u']; } if (isset($_POS ...

Numerous Kendo windows are layered on top of each other, yet the text divisions within them remain distinct

I am currently working on a project that involves laying out multiple Kendo windows in rows. Specifically, I need to display 4 windows in each row and have them shift left when closed. My framework of choice is Bootstrap 3. Everything works as expected w ...

Is adding a property to a div using the Jquery Css Function taking longer than expected?

I am attempting to scale a div when another is clicked, with the scaling origin starting from where the click occurred. This is similar to Apple's behavior when you open an app and it expands from where you clicked. However, I'm facing an issue ...

What is the best way to ensure my arrow text remains properly positioned when using fullpage.js?

Seeking guidance from the web development community. I am currently working on a client's website that utilizes fullpage.js and encountering a persistent issue. On slide1 of the website, I am struggling to display the correct text next to the arrows. ...

Guide to setting variables in a Mailgun email template using Node.js

I have developed a Google Cloud Function that sends an email with variables obtained from another source. I am using mailgun.js and attempting to send the email using a pre-existing template in Mailgun. The challenge I'm facing is finding a way to rep ...

What is the best way to activate a click event when I set a radio button to checked?

I am facing an issue with an uninitialized property in my app.component.ts: color!:string; I am trying to automatically initialize the color property when a radio button is selected: <div> <input type="radio" name="colors" ( ...

Creating a scrollable HTML5 div container with fixed divs positioned within it

I am attempting to develop an app container that mimics the functionality of Microsoft Excel. The container should scroll both horizontally and vertically, with fixed headers on the left and top that move along with the content. Here is a rough representat ...

"Enhance your Vue components with a directive to customize or adjust element attributes

I have a variety of elements structured like this: <some-custom-component :errors="formErrors.has(getErrorKey('town'))" :error-messages="formErrors.getAll(getErrorKey('town'))" ></some-custom-component> The formErrors ...

Viewing a PDF within a MUI tooltip

Currently, I am facing an issue where I am attempting to show a preview of a PDF file inside a Material-UI (MUI) Tooltip when a user hovers over a MUI ListItem. While I have successfully displayed previews of PNG and JPG files using Next.js' Image com ...

The Ajax request relies on the initial conditions (then)

My goal is to use the initial function to verify if an item exists and if it can be added to the PHP $_session. The aim is to limit the $_Session to a maximum of 3 items, returning 1 if the item already exists in the session. This enables the favorite fun ...