gpt4 book ai didi

html - 我似乎无法弄清楚为什么我的汉堡包按钮在我的导航栏上不起作用

转载 作者:行者123 更新时间:2023-11-28 02:30:07 25 4
gpt4 key购买 nike

我想知道是否有人知道为什么我的汉堡包按钮不会落在我的导航栏上?我不确定我是否没有上传正确的 JS 文件或什么?我的 JS 文件中也有一个 scrollspy 函数。

    <!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional Theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">

<link rel="stylesheet" href="{% static 'socialnet/css/style.css' %}">

</head>
<body data-spy="scroll" data-target="#navbar-spy">

<nav role = "navigation" class = "navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbarCollapse" 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 = "{% url 'home' %}">Social Net</a>
</div>
<div class="navbar-spy">
<div class="collapse navbar-collapse">
<ul class = "nav navbar-nav pull-right">
{% if user.is_authenticated %}
<li><a href ="{% url 'posts:create' %}" class="btn btn-simple">Post</a></li>
<li><a href ="{% url 'groups:all' %}" class="btn btn-simple">Groups</a></li>
<li><a href ="{% url 'groups:create' %}" class="btn btn-simple">Create Group</a></li>
<li><a href ="{% url 'accounts:logout' %}" class="btn btn-simple">Logout</a></li>
{% else %}
<li><a href ="{% url 'groups:all' %}" class="btn btn-simple">Groups</a></li>
<li><a href ="{% url 'accounts:login' %}" class="btn btn-simple">Login</a></li>
<li><a href ="{% url 'accounts:signup' %}" class="btn btn-simple">Signup</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
</nav>

<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript" src="{% static 'socialnet/js/master.js' %}"></script>
</body>
</html>

最佳答案

你错过了id="navbarCollapse"<div class="collapse navbar-collapse">

这被 <button> 引用了的 data-target="#navbarCollapse"

<div class="navbar-spy">
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class = "nav navbar-nav pull-right">
{% if user.is_authenticated %}
<li><a href ="{% url 'posts:create' %}" class="btn btn-simple">Post</a></li>
<li><a href ="{% url 'groups:all' %}" class="btn btn-simple">Groups</a></li>
<li><a href ="{% url 'groups:create' %}" class="btn btn-simple">Create Group</a></li>
<li><a href ="{% url 'accounts:logout' %}" class="btn btn-simple">Logout</a></li>
{% else %}
<li><a href ="{% url 'groups:all' %}" class="btn btn-simple">Groups</a></li>
<li><a href ="{% url 'accounts:login' %}" class="btn btn-simple">Login</a></li>
<li><a href ="{% url 'accounts:signup' %}" class="btn btn-simple">Signup</a></li>
{% endif %}
</ul>
</div>
</div>

关于html - 我似乎无法弄清楚为什么我的汉堡包按钮在我的导航栏上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51180780/

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