gpt4 book ai didi

css - 两个导航栏合并为 1 个用于移动设备?

转载 作者:太空宇宙 更新时间:2023-11-04 11:48:32 25 4
gpt4 key购买 nike

我在 Bootstrap 3 中有两个菜单 - 社交菜单和主菜单。当在移动设备上折叠时,我有两个菜单打开/切换按钮来打开相应的菜单项。

有什么方法可以在折叠时将社交菜单项移到主菜单中,并只使用一个切换/菜单按钮和列表?代码如下...

<div id="social-menu" class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-social">
<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 navbar-menubuilder">
<ul class="nav navbar-nav navbar-social">
<li>Social Menu Item 1</li>
<li>Social Menu Item 2</li>
<li>Social Menu Item 3</li>
<li>Social Menu Item 4</li>
</ul>
</div>
</div>
</div>


<div id="main-menu" class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-menu">
<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 navbar-menubuilder">
<ul class="nav navbar-nav navbar-main-menu">
<li>Main Menu Item 1</li>
<li>Main Menu Item 2</li>
<li>Main Menu Item 3</li>
<li>Main Menu Item 4</li>
</ul>
</div>
</div>
</div>

使用 Bootstrap 3

最佳答案

将第二个导航栏复制到与主导航栏相同的列表中。然后将类添加到主导航栏以在大型桌面上隐藏它们。

<div id="main-menu" class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-menu">
<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 navbar-menubuilder">
<ul class="nav navbar-nav navbar-social">
<li>Main Menu Item 1</li>
<li>Main Menu Item 2</li>
<li>Main Menu Item 3</li>
<li>Main Menu Item 4</li>
<li class="hidden-md hidden-lg">Social Menu Item 1</li>
<li class="hidden-md hidden-lg">Social Menu Item 2</li>
<li class="hidden-md hidden-lg">Social Menu Item 3</li>
<li class="hidden-md hidden-lg">Social Menu Item 4</li>
</ul>
</div>
</div>
</div>

关于css - 两个导航栏合并为 1 个用于移动设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30810982/

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