gpt4 book ai didi

html - Bootstrap 导航的移动菜单

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:29 24 4
gpt4 key购买 nike

我的导航形式略有不同。结构是这样的

<nav class="navbar navbar-fixed-left vertical-center" role="navigation">
<ul class="nav navbar-nav">
<li><a class="page-scroll" href="#hero"><span>H</span><span>O</span><span>M</span><span>E</span></a></li>
<li><a class="page-scroll" href="#portfolio"><span>W</span><span>O</span><span>R</span><span>K</span></a></li>
<li><a class="page-scroll" href="#about"><span>A</span><span>B</span><span>O</span><span>U</span><span>T</span></a></li>
<li><a class="page-scroll" href="#contact"><span>C</span><span>O</span><span>N</span><span>T</span><span>A</span><span>C</span><span>T</span></a></li>
</ul>
</nav>

我使用 CSS 将菜单垂直向下显示在页面的一侧。我已经设置了一个 JSFiddle进行演示。

我的问题是关于如何让它切换到移动设备上的标准 Bootstrap 移动菜单?

谢谢

最佳答案

是这样的吗? Pnkr

     <nav id="mainNav" class="navbar navbar-fixed-left vertical-center">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navCollapsed">
<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" id="navCollapsed">
<ul class="nav navbar-nav navbar-right">
<li><a class="page-scroll" href="#hero"><span>H</span><span>O</span><span>M</span><span>E</span></a></li>
<li><a class="page-scroll" href="#portfolio"><span>W</span><span>O</span><span>R</span><span>K</span></a></li>
<li><a class="page-scroll" href="#about"><span>A</span><span>B</span><span>O</span><span>U</span><span>T</span></a></li>
<li><a class="page-scroll" href="#contact"><span>C</span><span>O</span><span>N</span><span>T</span><span>A</span><span>C</span><span>T</span></a></li>
</ul>
</div>
</div>
</nav>

在菜单折叠时添加了一个按钮,当到达导航栏断点时会显示该按钮。然后将列表项添加到此按钮下。

我使用媒体查询来切换样式并删除导航栏的垂直对齐方式。

关于html - Bootstrap 导航的移动菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41513990/

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