我想知道是否有人知道为什么我的汉堡包按钮不会放在导航栏上?我不确定是否没有上传正确的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>
答案 0 :(得分:0)
您在id="navbarCollapse"
上缺少<div class="collapse navbar-collapse">
<button>
的{{1}}引用了
data-target="#navbarCollapse"