2014-02-22 495 views
14
<!DOCTYPE html> 
<html lang="de"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <!--<meta charset="utf-8"> --> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Stadtfestlauf - Start</title> 
    <link rel="icon" type="image/png" href="favicon.png" /> 

    <!-- Bootstrap --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]--> 
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
    <!--script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> 
    <![endif]--> 
</head> 
<body id="avcontent"> 
    <nav class="navbar navbar-default navbar-inverse" role="navigation"> 
    <div class="container-fluid" id="navfluid"> 
     <div class="navbar-header"> 
     <button type="button" class="navbar-toggle" 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="./Index.html">Stadtfestlauf</a> 
    </div> 
<div class="collapse navbar-collapse" id="navigationbar"> 
<ul class="nav navbar-nav"> 
    <li class="active"><a href="./Index.html">Startseite</a></li> 
    <li><a href="./Rueckblick.html">R&uuml;ckblick</a></li> 
    <li><a href="./Wettbewerb.html">Wettbewerb</a> 
    <li><a href="./anmelden.html">Anmelden</a> 
    <li><a href="./sponsoren.html">Sponsoren</a> 
</ul> 
</div><!-- /.navbar-collapse --> 
</div><!-- /.container-fluid --> 
</nav> 

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script src="https://code.jquery.com/jquery.js"></script> 
<!-- Include all compiled plugins (below), or include individual files as needed --> 
<script src="js/bootstrap.min.js"></script> 
<script type="text/javascript"> 
if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 
var msViewportStyle = document.createElement("style"); 
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}" 
) 
); 
document.getElementsByTagName("head")[0]. 
appendChild(msViewportStyle); 
} 
</script> 

<div class="container" id="pcontent"> 
    <div class="col-md-7"> 
    <div class="jumbotron"> 
     <h1>Hallo</h1> 
     <p>sample text</p> 

     <div class="wrapper"> 
     <p><a class="btn btn-primary btn-lg" role="button" id="sendButton" href="http://google.com/">Ich bin hier vollkommen Falsch</a></p> 
     </div> 
    </div> 
</div> 

<div class="col-md-5" id="imgslide"> 
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> 
    <ol class="carousel-indicators"> 
     <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> 
     <li data-target="#carousel-example-generic" data-slide-to="1"></li> 
     <li data-target="#carousel-example-generic" data-slide-to="2"></li> 
    </ol> 
    <div class="carousel-inner"> 
     <div class="item active"> 
    <img src="Assets/img1.jpg" alt="Stadtfestlauf" id="img"> 
     </div> 
     <div class="item"> 
    <img src="Assets/img2.jpg" alt="Stadtfestlauf" id="img"> 
     </div> 
     <div class="item"> 
     <img src="Assets/img3.jpg" alt="Stadtfestlauf" id="img"> 
     </div> 
    </div> 
</div> 
</div> 
</div> 
</body> 
</html> 

這是我的index.html。當我在手機上試用時,導航欄不起作用。我搜索了缺少div的標籤。「Mobile」Bootstrap-Navbar not working

+2

有幾個未關閉的標籤,我真想再看看。 – digitalextremist

+0

sry。我沒有找到任何。 – thegesuser

回答

38

您需要將您的按鈕的data-target更改爲您的navbar-collapse元素的ID。

此外,您的HTML缺少一些關閉<li>的。

Working Example

更改您的導航代碼如下:

<nav class="navbar navbar-default navbar-inverse" role="navigation"> 
    <div class="container-fluid" id="navfluid"> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar"> 
       <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="./Index.html">Stadtfestlauf</a> 
     </div> 
     <div class="collapse navbar-collapse" id="navigationbar"> 
      <ul class="nav navbar-nav"> 
       <li class="active"><a href="./Index.html">Startseite</a></li> 
       <li><a href="./Rueckblick.html">R&uuml;ckblick</a></li> 
       <li><a href="./Wettbewerb.html">Wettbewerb</a></li>  
       <li><a href="./anmelden.html">Anmelden</a></li> 
       <li><a href="./sponsoren.html">Sponsoren</a></li> 
      </ul> 
     </div><!-- /.navbar-collapse --> 
    </div><!-- /.container-fluid --> 
</nav> 
+0

非常感謝!它現在工作了! – thegesuser

+0

很高興能幫到你! – Sebsemillia

+0

謝謝!有同樣的問題,現在也適用於我! :) –

18

這也是有必要進口的引導,按順序,它不會工作之前導入的jQuery。它應該是這樣的:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

+1

謝謝你,我被告知這裏沒有什麼愚蠢的問題,所以這裏是:你怎麼知道這樣的事情,以及如何調試它? –

+3

我知道這是因爲我犯了這個錯誤,它(簡單地)使我瘋狂。代碼是正確的,我確信!我通過在一段代碼(通常是評論)和測試之後取出一塊來進行調試,使其更簡單,更簡單,直到我將其分解(然後我知道在哪裏查找)。然後,因爲需要很長時間才能找到,我記得那段旅程。 :) –

+0

.duh!謝啦。 – Milan