The dropdown menu is closing too quickly when hovered over

I'm having an issue with my dropdown menu closing quickly on hover and not staying open when I try to click it. I do need some margin as well.

 <div class="container mt-5 pt-5 ">
 <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
 <div class="collapse navbar-collapse ">
  <ul class="navbar-nav">
   <li class="nav-item dropdown">
    <a class="nav-link text-danger" href="#" id="Dropdown" role="button" 
    data-toggle="dropdown">HOVER IT</a>
            <div  class="dropdown-menu  mt-5" aria-labelledby="Dropdown">
              <a class="dropdown-item" href="#">1</a>
              <a class="dropdown-item" href="#">2</a>
              <a class="dropdown-item" href="#">3</a>
            </div>
   </li>
  </ul>
 </div>
 </nav>
 </div>

  CSS:
 .navbar-nav li:hover > .dropdown-menu {
  display: block;
  transition-delay: 5s;
  }

https://codepen.io/booyr/pen/wvwMxvX

Answer №1

To achieve a slow show and hide effect on your dropdown, you can utilize the CSS properties opacity: 0; visibility: hidden;. Then, upon hover, you can add opacity: 1; visibility: visible;.

Here is an example:

.navbar-nav li:hover > .dropdown-menu {
  opacity: 1; visibility: visible;
}
  
.navbar-nav li > .dropdown-menu {
  opacity: 0; visibility: hidden;
  transition-delay: 3s;
}

Thank you.

Answer №2

Customizing Your CSS:

.navbar-nav li:hover > .dropdown-menu {
    display: block;
    transition-delay: 5s; <----- Easily adjust the speed of your menu animation 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

Header text refuses to cooperate and center itself

Struggling to find the best way to center the "Header" text while keeping the icon in place. I've tried using text-align: center;, but it's not producing the desired results. Could anyone provide guidance on how to achieve this? Thanks. IMG: ...

Strikethrough text with a distinct color similar to that seen in email messages

In my endeavor to customize the line-through text decoration in red and change the text color to black or any other color for an email, I have experimented with various methods. These include wrapping the text in a span and setting its color to red, using ...

Unlocking the Power of JavaScript: Harnessing Its Potential for Numerous IDs in HTML

There's a script I came across on the internet at this link: let multi = 2; let str = "Little lamb"; let multiStr = ""; while(multi > 0){ multiStr += str multiStr += " "; multi--; } multiStr = multiStr.trimEnd ...

variable identifier looping through elements

I'm attempting to assign a dynamic ID to my div using ng-repeat. Here's an example: <div id="$index" ng-repeat="repeat in results.myJsonResults"> <div id="$index" ng-click="saveID($index)" ng-repeat="subRepeat in results.myJsonResul ...

How can I import HTML files using PHP?

Currently, I have a file structured like this: <?php if(some condition) { //Access Denied } else { echo "<html>My HTML Code</html>"; } ?> However, I am looking to optimize my PHP file by simplifying it with the following structu ...

What is the method for keeping the first column of the table fixed in place?

Incorporating jquery EasyUI, I have created a table where I want the first column to remain static while the rest of the columns scroll when the screen size is reduced. Code snippet available here. Is there a way to freeze just the Title1 column? I attem ...

What is the best method to make a hyperlink within an IFrame open in a new window?

Let me share the code I've been working on: <!DOCTYPE html> <html> <head> <base target="_blank"> </head> <body> <div style="border: 2px solid #D5CC5A; overflow: hidden; margin: 15px auto; max-width: 800px; ...

Ways to incorporate a conditional statement within a dropdown menu

When a user interacts with a dropdown, I want to conditionally show different choices based on their selection. If the user clicks on a checkbox, a specific set of options will appear; if they click on a radio button, another set of options will appear. h ...

Using Ajax to dynamically load page content into a div based on a selection made in a

How can I dynamically load content into a div using Ajax based on the selection made in a dropdown menu? For example, I have a select box with two options: test.HTML and test1.HTML. Below that, there is a div where I want to display the content from eithe ...

Having trouble retrieving the text of an element using Selenium

Looking at the DOM element provided: <span class="styles__Content-rlm06o-1 ixoRjG">20.00000000</span> I am attempting to extract the value 20.00000000 using the following Python code: text = driver.find_elements_by_xpath("//*[@c ...

What is the most effective way to upload HTML and CSS files on Google's servers?

Our website is basic with HTML, CSS, and JavaScript and we're looking to host it on Google's servers. Should we use App Engine or set up a web server using Compute Engine? If we opt for App Engine, we'll have to choose a programming langua ...

Encountering a problem with React components displaying incorrect sizes while utilizing flexbox styling

I am creating a basic test application using NextJS/React. Take a look at the code snippet below: The content of Board.tsx file: import './Board.css'; export default function Board() { return <div className="board"> < ...

In what way does Codesandbox create a resizable grid layout for components?

I am looking for guidance on implementing resizable windows like those in CodeSandbox and VS Code using React. How does CodeSandbox achieve this functionality? Could someone help me get started in the right direction? ...

What is the method for retrieving the font size of elements in the native view using appium?

Can the font size of text in the native view be retrieved using appium? I am aware of using driver.findElement(By.id("by-id")).getCssValue("font-size"); for web views. Is there a similar method for native views? ...

Creating a responsive design for mobile apps in Ionic using CSS

I need help with making my Ionic app responsive across all mobile devices. The design on the page was created using CSS, but it is not displaying properly on every device. How can I ensure that it adapts to different screen sizes? <template> <Io ...

Leveraging grunt in combination with php for the front end

Excuse me, I am new to using Grunt and I am not very familiar with PHP coding. I have started a new project and I am attempting to incorporate Grunt, which I find to be amazing, with some HTML files that contain minimal PHP code. Initially, I installed the ...

Tips for limiting the size of image uploads to under 2 megabytes

I am trying to implement an html select feature that allows users to upload images. <div class="row smallMargin"> <div class="col-sm-6"> Attach Image </div> <div class="col-sm-6"> <input type="file" ng-model="image" accept=" ...

the pop-up modal function is malfunctioning

I can't get my pop up to work properly. When I click the button, the screen dims as if a pop up is going to appear, but nothing shows up. Can someone please assist me with this issue? Here is the HTML file: <!DOCTYPE html> <html lang="en"&g ...

What are some creative ways to enhance closePath() in canvas styling?

Currently, I am faced with the challenge of styling the closePath() function on my canvas. Specifically, I would like to apply different stroke styles to each line segment. For now, let's focus on changing colors for each line. In the example below, y ...

AngularJS throwing error due to additional content following the document element during XML parsing

I've been working with Angular JS and recently created a basic login form with routing to navigate to the next page upon successful login. However, I've encountered an issue when trying to implement conditional routing. Although I can successful ...