The toggle button in the navbar takes its time to vanish completely

Every time I try to close my navbar, it seems to take forever for the navbar to disappear. Below is the code snippet:

HTML

<!-- logo -->
    <div class="logo">
        <img src="assets/logo.png" alt="logo g's shop">
    </div>
    <i class="ri-menu-line" id="menu-icon"></i>

<!-- nav -->
    <ul class="nav nav-pills nav-fill m4">
      <li class="nav-item">
        <a class="nav-link active .bg-white" aria-current="page" href="#">ALL ITEM</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">SMARTPHONES</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">LAPTOPS</a>
      </li>
    </ul>

CSS

.nav {
    position: absolute;
    z-index: 10001;
    top: 65px;
    right: 30px;
    width: 270px;
    background-color: #f3efef;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-radius: 4px;
    transition: all .50s ease;
    font-size: 14px;
}

.nav-item {
    margin-top: -2px;
    border-radius: 4px;
}

#menu-icon {
    display: block;
}

.nav.open {
    visibility: hidden;
}

JS (JQuery)

$('#menu-icon').click(function() {
    $('.nav').toggleClass('open');
});

Check out this video demonstrating the slow disappearance:

I would like the menus to disappear more quickly when clicked on.

Answer №1

Give this a shot - Delete the transition property

.nav {
    position: absolute;
    z-index: 10001;
    top: 65px;
    right: 30px;
    width: 270px;
    background-color: #f3efef;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-radius: 4px;
    font-size: 14px;
}

Answer №2

After making a simple adjustment, I successfully resolved the issue

.nav.open { visibility: hidden; }

by replacing it with

.nav.open { display: none; }

Appreciate the help!

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 causes the React app to fail in maintaining the login session with the Node.js server?

Greetings, I have a NodeJS server set up in two separate files: app.js and routes.js. The app.js file includes code for setting up the server, error handling, middleware configuration, and routing logic. The routes.js file contains specific route configu ...

Simple method for swapping out an HTML string with image tags solely using JavaScript

In our Ionic 2 App, we are displaying content from a backend API in the form of Questions and Answers. The Answers are generated using summernote, allowing us to render raw HTML in the app. However, we need to replace all instances of img tags in the answe ...

The boundary for the multipart/form-data in the $http post request is missing

I noticed that the boundary I set for the post call appears different in Chrome. How can I make my custom boundary "--test" display correctly on the request payload? var url = '/site/apkUpload'; var deferred = $q.defer(); console.log ...

Bootstrap modals are refusing to open

I have encountered an issue where the images are not displaying on my modal. I have tried changing both the images and the code itself, but being new to this, I am unsure of what exactly is causing the problem. Could it be a fault in the Javascript code or ...

Developing a sophisticated responsive menu using Bootstrap 5 and Flex

I need a responsive menu that always maintains the appearance shown in the image below. Any overflowing content should trigger the addition of a scrollbar: https://i.sstatic.net/Gen7g.png Although my current solution works initially, it fails when additi ...

Utilize pivot to manage user roles and permissions in ExpressJS application using Mongoose

My user schema is structured as shown below const userSchema = mongoose.Schema({ username: { type: String, required: true, }, first_name: { type: String, required: true, }, last_name: { type: Stri ...

Embracing Asynchronous Header Management in Ember.js

I am facing an issue where I need to asynchronously insert the headers into the adapter. The token function is responsible for checking if the token has expired, refreshing it via Ajax if needed, and then returning the new token. However, it appears that ...

Steps to activate ng-pattern exclusively when the field has been interacted with:

I've encountered a challenge with an input box that has an ng-pattern for link validation. Our project manager has requested that the text 'http://' be pre-filled in the input field, but doing so breaks the ng-pattern validation and prevents ...

Storing filtered data objects for future use

Introduction to my User Administration Page Currently, I am working on the User Administration page of my project and facing a minor issue. The page includes a table that displays material-ui's Usercard for each user in the system. These cards are ge ...

Tips for verifying if JavaScript has modified HTML after receiving an AJAX response

We are experimenting with scraping a website using Selenium and Java. For example, we want to change the product color on this page. How can we determine when the website's JavaScript has altered the HTML after an AJAX response? And how long should we ...

"Upon clicking the Bootstrap dropdown button, it mysteriously vanishes from

I am experiencing an issue where the button meant to reveal a dropdown menu is actually hiding the dropdown button itself. Interestingly, another dropdown menu in the same navigation works perfectly fine. <div class="side-nav pull-right"> <di ...

Ways to extract the text content from an element without mentioning the HTML tag

Could someone provide assistance with a problem I've encountered? So far, I haven't been able to find any solutions. I'm trying to extract the text 'You are logged in as' from the following HTML using XPath. However, since there a ...

Transmit information to PHP server using AJAX and FormData

FIX: I made some changes to the submit button and used a regular button instead. The code now works as intended. I also removed the HTML form altogether. I'm attempting to pass an image along with some text to my php script using ajax and formdata. H ...

How can we ensure all elements in a row are aligned at the top?

My goal is to position the elements in a row, which is enclosed within a container, at the top of that row. Here is the current structure of my HTML: <div class="container"> <div class="row"> <div class="ticket"> ...

Quotes Envelop HTML Content

When utilizing a Rich Text Editor to save data into a SQL database and retrieve it using a Databinder to display the value within a div, I encountered an issue where the HTML code is enclosed in quotes, causing it not to display properly. Below is a snipp ...

Unable to retrieve data from SpringBoot controller using $http.get request

I have developed an application that will execute queries on my store's database based on user input on the webpage. The backend method is functioning correctly and returns the response, but I am having trouble displaying the data in a dynamic table o ...

I'm not certain about the most effective method for loading the header, navigation, and footer on a website. While I have used PHP before, I

I have a collection of header.html, nav.html, and footer.html files that I want to incorporate into my index.php file. I currently use the require function to load them, but I'm unsure if this is the most efficient method. Here is an example of how I ...

Resizing an image based on the coordinates of a click position by utilizing jQuery

I'm new to experimenting with code, and I've been playing around with trying to shrink an image to nothing at a central point. I've found some success using a mix of the code snippet below and relative positioning in my CSS. $(function() ...

The Google Chrome console is failing to display the accurate line numbers for JavaScript errors

Currently, I find myself grappling with debugging in an angular project built with ionic framework. Utilizing ion-router-outlet, I attempt to troubleshoot using the Google Chrome console. Unfortunately, the console is displaying inaccurate line numbers mak ...

Tips for expanding Bootstrap 5 text area within tabbed interfaces

I am struggling to properly position a text area within a tab and have it stretch both horizontally and vertically within the card body. Despite trying to use d-flex and align-self-stretch, the tab content div does not seem to respond as expected. My att ...