TJEA TJEA - 2 months ago 7
CSS Question

Navbar not collapsing and can't work out why

I have these in my header rather than under the body as it said bootstrap needs jQuery to run:

<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


And this is the actual navbar part. I'm pretty sure something is missing but can't see what i'm doing wrong:

<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed navbar-right " data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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>
</div>
</button>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li id="button0"><a href="#landing-page">Home</a></li>
<li id="button1"><a href="#what-we-do">What We Do</a></li>
<li id="button2"><a href="#contact">Contact Us</a></li>
</div>
</ul>
</div>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

Answer

HTML Some Unwanted div change HTML

<nav class="navbar navbar-default navbar-fixed-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed navbar-right " data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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>
            </div>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
            <div class="navbar-collapse">
                <ul class="nav navbar-nav">
                    <li id="button0"><a href="#landing-page">Home</a></li>
                    <li id="button1"><a href="#what-we-do">What We Do</a></li>
                    <li id="button2"><a href="#contact">Contact Us</a></li>

                </ul>
            </div>
        </div>

    </nav>

https://jsfiddle.net/o6p71fko/1/