代码:
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="n-bar"></span>
<span class="n-bar"></span>
<span class="n-bar"></span>
</button>
<a class="navbar-brand" href="test"><img src="img/logo.png" alt=""/></a>
</div>
<div class="navbar-collapse collapse ">
<ul class="nav navbar-nav">
<li><a href="#">menu1</a></li>
<li><a href="#">menu2</a></li>
<li><a href="#">menu3</a></li>
</ul>
</div>
</div>
</div>
在这段代码中,我创建了一个bootstrap导航菜单,即menu1,menu2&amp;菜单3。现在,我希望当我将鼠标悬停在任何导航菜单上时,它会在菜单底部显示一个框,例如:https://www.flipkart.com/。那么,我该怎么办呢?请帮帮我。
谢谢
答案 0 :(得分:0)
试试这个:
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="n-bar"></span>
<span class="n-bar"></span>
<span class="n-bar"></span>
</button>
<a class="navbar-brand" href="test"><img src="img/logo.png" alt=""/></a>
</div>
<div class="navbar-collapse collapse dropdown">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
Button
</button>
<ul class="nav navbar-nav dropdown-list">
<li><a href="#">menu1</a></li>
<li><a href="#">menu2</a></li>
<li><a href="#">menu3</a></li>
</ul>
</div>
</div>
</div>
CSS:
.dropdown-list {
position: absolute;
display:none;
}
.dropdown {
position: relative;
}
.dropdown:hover .dropdown-list{
display:block;
}
这里jsFiddle https://jsfiddle.net/mhz86puo/2/