gpt4 book ai didi

html - Bootstrap-4 垂直导航栏卡住折叠

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

我才刚刚开始掌握 Bootstrap 。

我正在尝试在用户使用 bootstrap 4 滚动过整页“介绍”后在页面左侧创建一个垂直导航栏。下面的代码在页面左侧生成导航栏,但是有一个问题

  • 导航栏保持折叠状态,即使在再次调整窗口大小后也是如此

为什么代码会导致导航栏开始关闭?

谢谢,杰夫

<header id="home" class="jumbotron h-100vw w-100vw">
...
</header>
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<nav class="navbar navbar-expand-md navbar-light">

<a class="navbar-brand" href="#home">
<img src="img/logo.png" class="img-fluid" alt="Home">
</a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav-content" aria-controls="nav-content"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse-md flex-column" id="nav-content">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#about"></a>About Me</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#work">My Work</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#connect">Stay Connected</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Get In Touch</a>
</li>
</ul>
</div>
</nav>
</div>

<main class="col-md-10">
REST OF MY CONTENT ON THE RIGHT
</main>
</div>

最佳答案

没有 navbar-collapse-md 类。将其更改为 navbar-collapse

   <div class="collapse navbar-collapse flex-column" id="nav-content">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#about"></a>About Me
</li>
<li class="nav-item">
<a class="nav-link" href="#work">My Work</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#connect">Stay Connected</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Get In Touch</a>
</li>
</ul>
</div>

关于html - Bootstrap-4 垂直导航栏卡住折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49160235/

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