4

Bootstrap 下拉菜单对我不起作用。我做的一切都是正确的,你可以在那里看到:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<title>Test site | Jony</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Testing website coded by Jony - rapture-gfx" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="screen"/>
<link href='http://fonts.googleapis.com/css?family=Dosis' rel='stylesheet' type='text/css'><link rel="stylesheet" href="css/flexslider.css" type="text/css"><script     src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script><script     src="js/jquery.flexslider.js"></script><!-- Place in the <head>, after the three links -->    <script type="text/javascript" charset="utf-8">$(window).load(function() {      $('.flexslider').flexslider({    animation: "slide"  });});</script>
<link rel="stylesheet" href="flexslider.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="js/jquery.flexslider.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.lavalamp-1.4.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
$('.dropdown-toggle').dropdown()
</script>
</head>
<header>
<div class="header">
<div class="container">
<ul class="menu">
<li class="current"><span style="color: #bde2e1;">Home</li>

<li class="dropdown"><a class="dropdown-toggle" href="#">Servers</a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    <li class="hovering"><a href="#">Portfolio</a></li>
<li class="hovering"><a href="#">Releases</a></li>
<li class="hovering"><a href="#">Contact</a></li>
</ul>

</li>



<li class="hovering"><a href="#">Portfolio</a></li>
<li class="hovering"><a href="#">Releases</a></li>
<li class="hovering"><a href="#">Contact</a></li>
</ul>

Bootstrap 是一个现成的框架,具有网格系统、行、现成的 js 菜单等功能。

有一个解释它是如何工作的:

http://twitter.github.com/bootstrap/javascript.html#dropdowns 它对我不起作用。

是的,我src的 JS 文件链接正确。

4

2 回答 2

4

body你在你的 html 中丢失了。

将您的脚本放在页面底部或准备好后:

<script type="text/javascript">
$(function(){
    $('.dropdown-toggle').dropdown();
});
</script>

演示:http: //jsfiddle.net/rLL75/

编辑:

使用较新版本的 jquery。

于 2012-08-23T10:51:45.563 回答
0
<header>
    <div class="navbar navbar-static header">
        <div class="navbar-inner container">
            <ul class="nav" role="navigation">
               <li class="brand"><span style="color: #bde2e1;">Home</span></li>
               <li class="dropdown">
                   <a class="dropdown-toggle" id="drop4" role="button" data-toggle="dropdown" href="#">Dropdown <b class="caret"></b></a>
                   <ul id="menu1" class="dropdown-menu" role="menu" aria-labelledby="drop4">
                       <li><a tabindex="-1" href="#">Action</a></li>
                       <li><a tabindex="-1" href="#">Another action</a></li>
                       <li><a tabindex="-1" href="#">Something else here</a></li>
                       <li class="divider"></li>
                       <li><a tabindex="-1" href="#">Separated link</a></li>
                   </ul>
               </li>
               <li class="hovering"><a href="#">Portfolio</a></li>
               <li class="hovering"><a href="#">Releases</a></li>
               <li class="hovering"><a href="#">Contact</a></li>
           </ul>
           <div id="logo"><a href="#"><img src="img/logo.png" /></a></div>
       </div>
    </div>
</header>

<script type="text/javascript">
    $(function(){
        $('.dropdown-toggle').dropdown();
    });
</script>
于 2012-08-23T13:04:33.293 回答