我在我的网络应用程序上使用twitter bootstrap来完成所有样式,大部分内容都很棒.问题是,当我单击下拉图标时,我的导航栏一旦折叠,就不会下拉.我已经列出了我的HTML,但我认为问题是我的javascript看到这个完全相同的代码:http://jsfiddle.net/YWUmb/30/工作得很好.
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">Exployre</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/profile">Profile</a></li>
<li><a href="/sponsors">Sponsors</a></li>
<li><a href="/working">Exployrers</a></li>
<li><a href="/about">About</a></li>
<li><a href="/share">Share</a></li>
<li>
{% if user %}
User: {{ user }}<br>
<a href="{{ logout }}">logout</a>
{% else %}
<a href="/login">Signin or Register</a>
{% endif %}
<li>
<a href="/profile">
{% if visits %}
{% if visits > 10 %}
Prestige: {{ visits }}
{% elif visits > 5 %}
{% endif %}
{% endif %}
</a>
</li>
<li>
<form action="/search" class="navbar-search">
<div>
<input type="text" placeholder="Search" class="search-query" name="q" size="55"/>
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-Box&lang=en"></script>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<script type="text/javascript" src="/static/js/bootstrap.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
解决方法:
问题在于你的js的顺序.首先是jQuery脚本,bootstrap插件是:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.js"></script>