gpt4 book ai didi

javascript - Bootstrap 折叠侧边栏菜单到下拉菜单

转载 作者:可可西里 更新时间:2023-11-01 14:47:11 24 4
gpt4 key购买 nike

当屏幕尺寸为 XS(移动设备)时,我有一个带有垂直菜单的左侧边栏,我想要的是“nav nav-pills nav-stacked”,此菜单更改为合适的下拉菜单并以关闭/折叠开始。

这是我的起始代码:

http://www.bootply.com/zOy2IJumZO

这里也是html代码

<div class="container-fluid">
<div class="row">

<div class="col-xs-12 col-sm-3">

<div class="panel panel-info">
<div class="panel-heading">Categories <span class="badge pull-right">12345</span></div>
<ul id="categories-menu" class="nav nav-pills nav-stacked">
<li id="cid-1"><a href="automotive-vehicles">Automotive Vehicles</a></li>
<li id="cid-8"><a href="business-to-business">Business-to-Business</a></li>
<li id="cid-10"><a href="community">Community</a></li>
<li id="cid-2"><a href="electronics">Electronics</a></li>
<li id="cid-11"><a href="events">Events</a></li>
<li id="cid-12"><a href="fashion">Fashion</a></li>
<li id="cid-13"><a href="freebies">Freebies</a></li>
</ul>
</div>

<div class="panel panel-primary">
<div class="panel-heading">Site statistics</div>
<ul class="list-unstyled">
<li>1000 Users</li>
<li>200 Online</li>
<li>300 Hidden</li>
</ul>
</div>

</div>

<div class="col-xs-12 col-sm-9">
This is the right content column<br>
This is the right content column<br>
This is the right content column<br>
This is the right content column<br>
This is the right content column<br>
This is the right content column<br>
This is the right content column<br>
</div>

</div>
</div>

最佳答案

用 bootstrap collapse 类包装你的 ul:

<div class="collapse navbar-collapse" id="collapse">  
<ul id="categories-menu" class="nav nav-pills nav-stacked">
<li id="cid-1"><a href="automotive-vehicles">Automotive Vehicles</a></li>
<li id="cid-8"><a href="business-to-business">Business-to-Business</a></li>
<li id="cid-10"><a href="community">Community</a></li>
<li id="cid-2"><a href="electronics">Electronics</a></li>
<li id="cid-11"><a href="events">Events</a></li>
<li id="cid-12"><a href="fashion">Fashion</a></li>
<li id="cid-13"><a href="freebies">Freebies</a></li>
</ul>
</div>

然后将 data-toggle 和 data-target 添加到要切换菜单的元素。例如代码中的徽章 12345:

<span data-toggle="collapse" data-target="#collapse" class="badge pull-right">

关于javascript - Bootstrap 折叠侧边栏菜单到下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28254150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com