gpt4 book ai didi

html - 为什么折叠 View 按钮在我的导航栏上不起作用?

转载 作者:行者123 更新时间:2023-11-28 16:34:03 24 4
gpt4 key购买 nike

Bootstrap 提供以下代码用作导航栏。然而,当我简单地粘贴他们的代码而不改变它时,折叠 View 不起作用。当您将浏览器窗口的大小调整得更窄时,导航栏会变成一个按钮,您可以单击该按钮以再次显示所有导航组件。但是,当我简单地粘贴他们的代码时,它似乎不起作用。有人知道为什么吗?导航组件会折叠,但单击按钮显示它们不会执行任何操作。

<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

HTML

<?php include('config/setup.php'); ?>   

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Search Hound</title>

<!--This enables the website to be mobile first-->
<meta name="viewport" content="width=device-width, initial-scale=1">

<?php include('config/js.php'); ?>

<?php include('config/css.php'); ?>



</head>

<body>

<?php include('template/navigation.php'); ?>

<div class="container">
<form class="form-inline" align="center">

<!-- Section to type question-->
<div class="form-group" style="display:block">
<textarea class="form-control" style="width:100%" rows="5"></textarea>
</div>

<!--Section to add money-->
<div class="input-group" id="AddMoney">
<span class="input-group-addon">$</span>
<input id="EnterMoney" type="text" class="form-control" onkeypress='validate(event)' aria-label="Amount (in dollars and cents)">
</div>

<!--Section to add file-->
<div id="AddFile">
<a href="#" onclick="document.getElementById('uploadFile').click(); return false;">Add File</a>
<input type="file" id="uploadFile" style="visibility: hidden;" />
</div>

<div id="imagePreview"></div>

<!--Section for the Submit button-->
<div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
<!-- /container -->

<div

</body>

<?php include('template/footer.php'); ?>

</html>

config/js.php

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

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

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

最佳答案

我没有看到您在 bootstrap.js 文件之前包含了 jQuery。需要 jQuery 才能使用 bootstrap javascript 组件。

config/js.php 文件中的 bootstrap.js 之前添加这个。

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

关于html - 为什么折叠 View 按钮在我的导航栏上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31642845/

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