user1398287 user1398287 - 11 days ago 8
Javascript Question

Make Bootstrap's YAMM open on hover

I'm using the YAMM to create a mega menu for Bootstrap but I can't figure out how to make the menu appear on mouseover/hover. At the moment it only appears on click.

github demo

jsFiddle



<div class="container">

<div class="navbar yamm">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#nav1">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#"> Yamm Megamenu </a>
<div class="nav-collapse collapse" id="nav1">
<ul class="nav">
<!-- Classic list -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> List <b class="caret"></b> </a>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<ul class="span2 unstyled">
<li><p><strong>Section Title</strong></p></li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
</ul>
<ul class="span2 unstyled">
<li><p><strong>Links Title</strong></p></li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</ul>
<ul class="span2 unstyled">
<li><p><strong>Section Title</strong></p></li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</ul>
<ul class="span2 unstyled">
<li><p><strong>Section Title</strong></p></li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
<ul>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
<li>
<a href="#"> Link Item </a>
</li>
</ul>
</li>
</ul>
</div>
</li>
</ul>
</li>
<!-- Accordion demo -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> Accordion <b class="caret"></b> </a>
<ul class="dropdown-menu">
<li>
<div class="yamm-content">
<div class="row-fluid">
<div id="accordion2" class="accordion span6">
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseOne" data-parent="#accordion2" data-toggle="collapse" class="accordion-toggle collapsed"> Collapsible Group Item #1 </a>
</div>
<div class="accordion-body collapse" id="collapseOne" style="height: 0px;">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseTwo" data-parent="#accordion2" data-toggle="collapse" class="accordion-toggle"> Collapsible Group Item #2 </a>
</div>
<div class="accordion-body collapse" id="collapseTwo">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseThree" data-parent="#accordion2" data-toggle="collapse" class="accordion-toggle"> Collapsible Group Item #3 </a>
</div>
<div class="accordion-body collapse" id="collapseThree">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
<div id="accordion3" class="accordion span6">
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseOne1" data-parent="#accordion3" data-toggle="collapse" class="accordion-toggle collapsed"> Collapsible Group Item #1 </a>
</div>
<div class="accordion-body collapse" id="collapseOne1" style="height: 0px;">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseTwo1" data-parent="#accordion3" data-toggle="collapse" class="accordion-toggle"> Collapsible Group Item #2 </a>
</div>
<div class="accordion-body collapse" id="collapseTwo1">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a href="#collapseThree1" data-parent="#accordion3" data-toggle="collapse" class="accordion-toggle"> Collapsible Group Item #3 </a>
</div>
<div class="accordion-body collapse" id="collapseThree1">
<div class="accordion-inner">
Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
</div>
</div>
</li>
</ul>
</li>
<!-- Classic dropdown -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> Classic <b class="caret"></b> </a><!-- Classic Dropdown -->
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
<li>
<a tabindex="-1" href="#"> Action </a>
</li>
<li>
<a tabindex="-1" href="#"> Another action </a>
</li>
<li>
<a tabindex="-1" href="#"> Something else here </a>
</li>
<li class="divider"></li>
<li>
<a tabindex="-1" href="#"> Separated link </a>
</li>
</ul>
</li>
<!-- Pictures -->
<li class="dropdown yamm-fullwidth">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> Pictures <b class="caret"></b> </a>
<ul class="dropdown-menu">
<li>
<div class="yamm-content">
<!-- thumbnails needs a row-fluid to make span fluid -->
<div class="row-fluid">
<ul class="thumbnails">
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
<li class="span2">
<a class="thumbnail" href="#"> <img alt="150x190" data-src="holder.js/150x90"> </a>
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>

</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

Answer

You need to make display: block when the particular li is hoverd.

Add this in your css code

ul.nav li.dropdown:hover > ul.dropdown-menu {
    display: block;    
}