我正在使用Bootstrap'List group',我需要让它响应。 在移动视图中表示,该列表将显示为导航栏等下拉按钮。
我尝试过nav类,但没有按预期工作。 代码:
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#side-menu-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="list-group collapse navbar-collapse" id="#side-menu-collapse">
<li class="list-group-item dropdown-toggle">Cras justo odio</li>
<li class="list-group-item dropdown-toggle">Dapibus ac facilisis in</li>
<li class="list-group-item dropdown-toggle">Morbi leo risus</li>
<li class="list-group-item dropdown-toggle">Porta ac consectetur ac</li>
<li class="list-group-item dropdown-toggle">Vestibulum at eros</li>
</ul>
答案 0 :(得分:17)
您可以通过一些媒体查询来完成此操作。在屏幕大小不同于collapse
时覆盖XS
类。
Bootply :http://www.bootply.com/120504
CSS :
@media screen and (min-width: 768px) {
.custom-collapse .collapse{
display:block;
}
}
HTML :
<div class="custom-collapse">
<button class="collapse-toggle visible-xs " type="button" data-toggle="collapse" data-parent="custom-collapse" data-target="#side-menu-collapse">
<span class="">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="list-group collapse" id="side-menu-collapse">
<li class="list-group-item dropdown-toggle">Cras justo odio</li>
<li class="list-group-item dropdown-toggle">Dapibus ac facilisis in</li>
<li class="list-group-item dropdown-toggle">Morbi leo risus</li>
<li class="list-group-item dropdown-toggle">Porta ac consectetur ac</li>
<li class="list-group-item dropdown-toggle">Vestibulum at eros</li>
</ul>
</div>