Can someone help me achieve a transition effect on my megamenu div using CSS? I tried adding visibility: hidden; opacity: 0; to the .submenu class and visibility: visible; opacity: 1; to ul.menu1 li:hover .submenu class. It works, but when I hover from one menu item to another, it automatically shows the previous menu code. For example, if I hover over the "Contact Us" menu and then hover over the "Products" menu, then move the mouse down to any link, it goes back to displaying the "Contact" menu code.
If I remove the visibility and opacity properties and simply add display:none; and display:block;, it works fine. However, I want my megamenu to appear with a light fade effect on hover.
I'm looking to replicate the mega-menu hover effect style of this website: .
I have attached both the HTML and CSS code for reference.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multi Level Drop Down Menu</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
... (HTML code not repeated for brevity)
*{ margin: 0; padding: 0; box-sizing: border-box; transition: all 0.3s; }
ul,li,p{ margin: 0; padding: 0; list-style: none; }
... (CSS code not repeated for brevity)