我正在制作下面的CSS下拉列表。它适用于移动版本,但对于桌面版本,它会产生问题。
<div class="container">
<div class="navbar-header">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-6"> <a class="navbar-brand" href="#/home"><img src="img/logo.png" class="img-responsive" alt="Learn Education" title="Learn Education"/></a></div>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
</div>
<div class="collapse navbar-collapse col-lg-6 col-md-6 col-sm-12 col-xs-7 pull-right" id="bs-example-navbar-collapse-1" style="border:none;border-radius:15px;">
<ul class="nav navbar-nav navbar-right changeme" id="visibid">
<li> <a href="#" data-toggle="collapse" data-target=".navbar-collapse">Home</a> </li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">LogIn</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">SignUp</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Sample Test <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">Mathematics</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">Physics</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">Chemistry</a></li>
</ul>
</li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">Reports</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">About Us</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">Contact Us</a></li>
<li><a href="#" data-toggle="collapse" data-target=".navbar-collapse">DashBoard</a></li>
</ul>
</div>
</div>
这是Plnkr。
要查看错误,请切换到全屏模式,然后按任意按钮。
答案 0 :(得分:1)
您需要从所有链接中删除data-target=".navbar-collapse" data-toggle="collapse"
- 这导致Bootstrap JS尝试折叠菜单
答案 1 :(得分:1)
添加媒体查询
@media screen and (min-width: 768px) {
#bs-example-navbar-collapse-1{
display:none;
}
}