gpt4 book ai didi

html - 为什么我的 Bootstrap Pills 下拉菜单不起作用?

转载 作者:行者123 更新时间:2023-11-28 08:22:46 26 4
gpt4 key购买 nike

我基本上是从 http://getbootstrap.com/components/ 复制了 Pills 下拉菜单的组件。但它根本行不通。当我单击菜单项时,下拉菜单不会出现。我将我的确切代码复制到 JSFiddle 中:https://jsfiddle.net/j63f0o2f/ .来自 JSFiddle 的片段:

<div class="nav">
<ul class="nav nav-pills nav-justified">
<li><a href="#">Robot Technology</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Webdesign <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">HTML 5</a></li>
<li><a href="#">CSS 3</a></li>
<li><a href="#">Bootstrap 5</a></li>
</ul>
</li>

最佳答案

您必须在 <head> 中插入 Bootstrap JavaScript 文件和 JQuery JavaScritp 文件。标签。仔细查看以下代码片段:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body>
<h1>Hello, world!</h1>
<div class="nav">
<ul class="nav nav-pills nav-justified">
<li><a href="#">Robot Technology</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Webdesign <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">HTML 5</a></li>
<li><a href="#">CSS 3</a></li>
<li><a href="#">Bootstrap 5</a></li>
</ul>
</li>
</ul>
</div>

</body>
</html>

关于html - 为什么我的 Bootstrap Pills 下拉菜单不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28670894/

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