英文:
Bootstrap 4.5 Navbar is not expanding for Collapsible items
问题
我的应用程序是基于Bootstrap 4.5构建的,使用Bootstrap建议的导航栏折叠项方法,图标可见但项目缺失。我有一个-navbar.scss文件,其中定义了所有属性。
我的HTML代码。
<nav class="navbar navbar-expand-md fixed-bottom bg-gray navbar-light justify-content-end">
<!-- 切换/折叠按钮 -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- 导航栏链接 -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Shades.html">Shades</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Climtes.html">Climates</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Settings.html">Settings</a>
</li>
</ul>
</div>
</nav>
截图:-
点击此处查看图片描述
点击此处查看图片描述
英文:
My application is build on Bootstrap 4.5 & using the bootstrap suggested method for Navbar collapse items, the icon is visible but items are missing. I have -navbar.scss which all the properties defined.
My HTML code.
<nav class="navbar navbar-expand-md fixed-bottom bg-gray navbar-light justify-content-end">
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Shades.html">Shades</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Climtes.html">Climates</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Settings.html">Settings</a>
</li>
</ul>
</nav>
Screenshots:-
enter image description here
enter image description here
答案1
得分: 0
上面的代码在您正确将Bootstrap 4添加到项目中时可以正常工作。请查看下面的代码片段:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class "nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class "nav-link" href="Shades.html">Shades</a>
</li>
<li class="nav-item">
<a class "nav-link" href="Climates.html">Climates</a>
</li>
<li class="nav-item">
<a class "nav-link" href="Settings.html">Settings</a>
</li>
</ul>
</div>
</nav>
希望对您有所帮助。
英文:
The code above works as expected if you add Bootstrap 4 to your project correctly.
See the snippet below.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="light.html">Lights</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Shades.html">Shades</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Climtes.html">Climates</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Settings.html">Settings</a>
</li>
</ul>
</div>
</nav>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论