Following the tutorial on YelpCamp. Also I read post on this site but still I can't figure out why the items of the menu did'nt show up when the hamburger menu is displayed:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Imperial Fleet</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/main.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="/">Imperial Fleet</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="/ships">Ships</a></li>
<li><a href="/fleets">Fleets</a></li>
<li><a href="/bases">Bases</a></li>
<% if(!currentUser){ %>
<li><a href="/login">Login</a></li>
<li><a href="/register">Sign up</a></li>
<% } else { %>
<li><a href="#">Signed in as: <%= currentUser.username %></a></li>
<li><a href="/logout">Logout</a></li>
<% } %>
</ul>
</div>
</div>
</nav>
<div class="container">
<% if (error && error.length > 0 ) { %>
<div class="alert alert-danger" role="alert">
<%= error %>
</div>
<% } %>
<% if (success && success.length > 0 ) { %>
<div class="alert alert-success" role="alert">
<%= success %>
</div>
<% } %>
</div>
The last <div class="container">
is only for displaying flash-connect messages
答案 0 :(得分:1)
您是否在页面上包含了js插件?
在Docs之后:
需要JavaScript插件
如果禁用了JavaScript并且视口足够窄,以至于 导航栏折叠,将无法展开导航栏并查看 .navbar折叠中的内容。
自适应导航栏要求将collapse plugin包含在其中 您的Bootstrap版本。
答案 1 :(得分:0)
错误在于这一行:
错误:
<div class="collapse navbar-collapse">
解决方案:
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
我忘记了id标签。