我有一个带有3个选项的bootstrap navbarsetup,然后是一个下拉菜单。这一切在我的浏览器上都很有效(下面的代码)
我想要做的是更改菜单,以便当汉堡包图标变为可见时,菜单显示在两列表中,其中显示所有项目(主要和下拉列表),而不是3个选项和“更多”。 ..“item
这可以通过bootstrap / CSS实现,还是我必须构建两个菜单?
@import 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css';
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="true">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-left" href="/home/"><span class="logo"></span></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse in" id="bs-example-navbar-collapse-1" aria-expanded="true" style="">
<ul class="nav navbar-nav navbar-right">
<li class="">
<a href="/opt1/">Option 1</a>
</li>
<li class="">
<a href="/opt2/">Option 2</a>
</li>
<li class="">
<a href="/opt3/">Option 3</a>
</li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">More...<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="">
<a href="/drop1/">Dropdown 1</a>
</li>
<li class="">
<a href="/drop2r/">Dropdown 2</a>
</li>
<li class="">
<a href="/drop3/">Dropdown 3</a>
</li>
<li class="">
<a href="/drop4/">Dropdown 4</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
答案 0 :(得分:0)
在这里:http://www.bootply.com/twaM4o0sej
您需要覆盖导致它在点击时打开的样式,而不是默认打开它。我还必须隐藏说&#34;更多&#34;对于移动设备,所以它不会出现。只需调整填充物就可以了。
<强> CSS:强>
@media only screen and (max-width:768px){
.dropdown-menu{
display: block;
position: static;
background-color:transparent;
border:0 none;
box-shadow:none;
margin-top:0;
position:static;
width:100%;
}
<强> HTML:强>
<li class="dropdown"><a href="#" class="dropdown-toggle hidden-xs" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">More...<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="">
<a href="/drop1/">Dropdown 1</a>
</li>
<li class="">
<a href="/drop2r/">Dropdown 2</a>
</li>
<li class="">
<a href="/drop3/">Dropdown 3</a>
</li>
<li class="">
<a href="/drop4/">Dropdown 4</a>
</li>
</ul>
</li>