You can use a mix of jQuery (for changing class) and CSS3 (for transition). So, you have your CSS well set, and make sure you set these two params:
.dropdown.show {transition: all 2s ease;}
.dropdown.hide {transition: all 2s ease;}
Now for the jQuery part, we will just be using it to change the class on click.
$(document).ready(function(){
$("nav > ul > li > a").toggle(function(){
$(this).next('.dropdown').removeClass("hide").addClass("show");
return false;
}, function(){
$(this).next('.dropdown').removeClass("show").addClass("hide");
return false;
});
});
For this, you need to have the .dropdown, positioned next to the links. This gets attached to the click event handler. If you want it on :hover, you can use this code:
$(document).ready(function(){
$("nav > ul > li > a").toggle(function(){
$(this).next('.dropdown').removeClass("hide").addClass("show");
return false;
}, function(){
$(this).next('.dropdown').removeClass("show").addClass("hide");
return false;
});
});
If you are planning for different sub-menus for each menu item, you need to add them next to the <a href...>...</a> tag inside the nav > ul > li. A sample code would be:
<div class="wrapper">
<nav>
<ul>
<li>
<a href="#">Home</a>
<div class="dropdown hide">
<!-- Dropdown Menu -->
</div>
</li>
</ul>
</nav>
</div>
In my opinion, you should not use two classes for the same div. A .hide and .show is not needed. Instead, have just the .hide be default and toggle between .show!