gpt4 book ai didi

javascript - Twitter Bootstrap、导航栏、下拉菜单无法正常工作

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

我正在尝试使用 Bootstrap 制作响应式导航栏。但是,下拉菜单无法正常工作。

我想在品牌名称下添加下拉菜单而不是它。

这是我的代码:

<html>
<head>
<meta name="viewport" content="width=device-width, intial-scale=1.0">
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<a href="#" class="navbar-brand">ACUPRESSURE</a>

<button type="button" class = "navbar-toggle" data-toggle ="collapse" data-target = ".navHeaderCollapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<div class = "collapse navbar-collapse navHeaderCollapse">

<ul class="nav navbar-nav navbar-right">
<li><a href ="#">Home</a></li>
<li><a href ="#">Home</a></li>
<li><a href ="#">Home</a></li>
<li><a href ="#">Home</a></li>
<li><a href ="#">Home</a></li>
</ul>
</div>
</div>
</div>
<script src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src= "js/bootstrap.js"></script>
</body>
</html>

最佳答案

您缺少围绕 navbar-togglenavbar-brandnavbar-header 类。查看Docs .

工作示例。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>

</button><a href="#" class="navbar-brand">ACUPRESSURE</a>

</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Home</a>

</li>
<li><a href="#">Home</a>

</li>
<li><a href="#">Home</a>

</li>
<li><a href="#">Home</a>

</li>
<li><a href="#">Home</a>

</li>
</ul>
</div>
</div>
</div>

关于javascript - Twitter Bootstrap、导航栏、下拉菜单无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33976864/

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