2016-09-22 81 views
0

我有這些在我的頭,而不是在身下,因爲它說,自舉需要jQuery來運行:導航欄沒有崩潰

<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> 

這是實際的導航欄的一部分。我敢肯定缺少的東西,但不能看到我做錯了什麼:

<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> 

回答

1

HTML一些不需要的div改變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/

+0

令人驚歎!在過去的幾個小時裏,這一直在融化我的大腦。謝謝! –

0

您已經添加了兩個分度,導航欄,垮垮類,去掉UL之前內部之一。

觀看演示

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<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> 
 

 
     <!-- Collect the nav links, forms, and other content for toggling --> 
 
     <div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1"> 
 
      
 
       <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><!-- /.container-fluid --> 
 
</nav>

+0

您已關閉按鈕中的'div'標記。並關閉列表中的'div'標籤('ul')。 – 3rdthemagical

+0

@ 3rdthemagical感謝和修改 –

+0

您忘記了'ul.nav navbar-nav'中的'div'。 – 3rdthemagical

0

刪除DIV在第17行和它的結束標記。另外,請刪除第11行和第22行的額外關閉div。

<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> 

     <!-- Collect the nav links, forms, and other content for toggling --> 
     <div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1"> 

      <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><!-- /.navbar-collapse --> 

    </div><!-- /.container-fluid --> 

</nav>