Bootstrap导航栏切换不适用于Laravel

时间:2015-06-17 08:37:42

标签: jquery html css twitter-bootstrap laravel

我已经关注了代码

<div class="container">
    <div class="row">
        <nav class = "navbar navbar-inverse navbar-fixed-top">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#topMenu" aria-expanded="false" aria-controls="navbar">
                    <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>
            <div class = "collapse navbar-collapse" id = "topMenu">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#" class = 'navAnchor'>Link</a></li>
                    <li><a href="#" class = 'navAnchor'>Link</a></li>
                    <li><a href="#" class = 'navAnchor'>Link</a></li>
                    <li><a href="#" class = 'navAnchor'>Link</a></li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </nav>
    </div>
</div>

我也试图改变

<div class = "collapse navbar-collapse" data-toggle="collapse" id = "topMenu">

但是当我调整屏幕大小以便在较小的屏幕上观看时,会出现3个条形图,但点击它们就什么都不做。

修改 在页面顶部

<link rel="stylesheet" href="{{ URL::asset('assets/css/bootstrap.min.css') }}" />

位于底部,body

<link rel="text/javascript" href="{{ URL::asset('assets/js/jquery.js') }}" />
<link rel="text/javascript" href="{{ URL::asset('assets/js/bootstrap.min.js') }}" />

通过查看控制台(检查元素,它没有显示错误),正确地加载了所有东西。 有人可以引导我走向正确的方式。

谢谢

2 个答案:

答案 0 :(得分:5)

问题在于您使用的# The views used below are normally mapped in django.contrib.admin.urls.py # This URLs file is used to provide a reliable view deployment for test purposes. # It is also provided as a convenience to those who want to deploy these URLs # elsewhere. 代码实际上应该使用link代码:

script

Javascript应该在脚本标记中,以便加载到您的页面中:

<link rel="text/javascript" href="{{ URL::asset('assets/js/jquery.js') }}" />
<link rel="text/javascript" href="{{ URL::asset('assets/js/bootstrap.min.js') }}" />

这应该可以解决您的问题

答案 1 :(得分:1)

您已将javascript放在链接标记内,而不是脚本标记。链接用于css和 js < / strong>我们使用脚本。 将它写在脚本标记内:

<script type="text/javascript" src="{{your_source_for_script}}"></script>