I am working on the CSS dropdown below. It is working fine for the mobile version but for the desktop version it is creating a problem.
我正在处理下面的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>
Here is the Plnkr.
这是Plnkr。
In order to see the error please switch to fullscreen mode and press any of those buttons.
为了查看错误,请切换到全屏模式并按下其中任何一个按钮。
2 个解决方案
#1
1
add media queries
添加媒体查询
@media screen and (min-width: 768px) {
#bs-example-navbar-collapse-1{
display:none;
}
}
#2
1
You need to remove data-target=".navbar-collapse" data-toggle="collapse"
from all the links - this is causing the Bootstrap JS to try and collapse the menu
您需要删除data-target="。从所有链接中折叠navbar-collapse“data-toggle=“折叠”——这导致引导程序JS尝试并折叠菜单
#1
1
add media queries
添加媒体查询
@media screen and (min-width: 768px) {
#bs-example-navbar-collapse-1{
display:none;
}
}
#2
1
You need to remove data-target=".navbar-collapse" data-toggle="collapse"
from all the links - this is causing the Bootstrap JS to try and collapse the menu
您需要删除data-target="。从所有链接中折叠navbar-collapse“data-toggle=“折叠”——这导致引导程序JS尝试并折叠菜单