I am working on a site and have created a navigation bar with sub-items but I am not getting these sub-items display on hover. Here's my HTML and CSS code for the navigation bar:
<div class="collapse navbar-collapse" id="spi-primary-nav">
<ul class="nav navbar-nav">
<li id="menu-item-9265" class="home-link menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-9001 current_page_item menu-item-9265">
<a href="index.html">Home</a>
</li>
<li id="menu-item-9004" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9004 ">
<a href="Default.aspx">Store</a>
<ul>
<li><a href="#">Sub Menu 1</a></li>
<li><a href="#">Sub Menu 2</a></li>
<li><a href="#">Sub Menu 3</a></li>
</ul>
</li>
</ul>
</div>
The CSS is here:
.navbar-nav > li > ul {
display: none;
position: absolute;
}
.navbar-nav > li > ul:hover {
display:block;
}
Here is the live link of the site in case someone wants to inspect the elements using Firebug: http://webcalendar.pcprosinc.com/Home
Please help me out
You got your :hover
in the wrong place.
It should be in the li
instead of the ul
Try this instead:
.navbar-nav > li:hover > ul {
display:block;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.